This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a servlet called DataServlet. When a call is made to DataServlet I need to make a check to see whethet the user has already logged in. If not I need to make a call in my DataServlet to LoginServlet with the aditional parameters... like LoginServlet?&cmd=LOGIN How do I make a call to another servlet in my currect servlet? Thanks.
I would strongly recommend against this. A much better solution is to refactor the login authentication functionality into a regular Java class, and use it from both of your servlets. As a rule, servlet classes should not contain business logic such as this, but instead be largely concerned with selecting the correct classes and methods to call to perform whatever operations are needed.
Dear Mr.Bala, You can call another servlet by using a method of Httprequest and including the output of that servlet in your Dataservlet.
Joined: Dec 14, 2000
Hello I am trying to altr the request attributes on an HttpServlet request object by using the methods: Hi I am able to that, I used the requestDispatcher's forward method. thanks. But I have a new problem. I want to add one more new value to the request. I am using, request.setAttribute(String,Object) and then using request dispatcher to forward the request from a servlet to another servlet, but the added attributes dont seem to forwarded, how do forward an request object along with the newly added value?
Joined: Nov 03, 2000
Try this code. It may work RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/jsp/temp.jsp?i="+ i); dispatcher.include(request, response); regards