Skip to main content
12 events
when toggle format what by license comment
Sep 20, 2016 at 7:38 vote accept Koray Tugay
Apr 28, 2014 at 6:19 comment added abuzittin gillifirca You should invest some time and learn Spring Framework, even if you do not use it, it will make Java application architecture more clear. Also, you can get more detailed answers from programmers SE. Most of your questions are probably answered there already.
Apr 26, 2014 at 15:13 comment added Koray Tugay @abuzittingillifirca Abuzittin, one question. What if I need to access the xyzService something that is not Servlet?
Apr 22, 2014 at 6:22 comment added abuzittin gillifirca Of course, if you are doing this not to learn workings of the Servlet API, but to develop production systems; you can use a framework such as Spring and save yourself a lot of time. Also, after moving service etc out of your web layer, next in order is to move any passwords etc out of your application code, for example if they exist in DatabaseConnectionImpl`. Standard way to do it is using JNDI. See here for how it is done for Tomcat. Each servlet container has a way of doing this.
Apr 21, 2014 at 17:14 comment added Koray Tugay @abuzittingillifirca Thanks. I will try this approach.
Apr 20, 2014 at 19:44 answer added JvR timeline score: 2
Apr 18, 2014 at 13:31 comment added abuzittin gillifirca You define a ServletContextListener in the web.xml. You create your services, factories etc in its contextInitialized method, and stick them into the ServletContext with setAttribute("some.prefix.xyzService", xyzService) etc. You can then get them back in the servlet with XyzService xyzService = (XyzService)(getServletContext().getAttribute("some.prefix.xyzService"));
Apr 18, 2014 at 12:49 comment added Koray Tugay @abuzittingillifirca I am not using any dependency injection container or anything else so how can I avoid new DatabaseConnectionImpl()?
Apr 18, 2014 at 11:00 comment added abuzittin gillifirca Short answer: You have new DatabaseConnectionImpl() and catch (SQLException e) in your servlet class, therefore your web layer is not separated from data access layer.
Apr 17, 2014 at 20:53 answer added Eddie Curtis timeline score: 3
Apr 17, 2014 at 20:30 history tweeted twitter.com/#!/StackCodeReview/status/456892488393822208
Apr 17, 2014 at 18:30 history asked Koray Tugay CC BY-SA 3.0