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.
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?