1

I am forwarding my request from Login servlet to a FacultyHomePage.jsp located in faculty folder(which is subfolder)....The page is displayed but url remains /LoginServlet. Why isn't the url changing??

    HttpSession sc= request.getSession();
          if(usertype==0)
          {
              sc.setAttribute("type", usertype);
              sc.setAttribute("id",id );
         rd=request.getRequestDispatcher("/faculty/FacultyHomePage.jsp");
         rd.forward(request, response);
          }
Vini
  • 119
  • 1
  • 3
  • 11

1 Answers1

5

New request object will not be created in request dispatcher. Check RequestDispatcher.forward method.

If you want a URL change then use response.sendRedirect(java.lang.String)

Ravindra Gullapalli
  • 9,049
  • 3
  • 48
  • 70
  • 1
    Yes thnx,that's working but now I am not getting the session created in my login servlet.Is this related to sendRedirect()??? – Vini Mar 20 '13 at 08:15
  • You can get session forcefully with the statement `session = request.getSession(true);` Before that you can check if a session already got created using `if(session != null){session = request.getSession(true);}`. – Ravindra Gullapalli Mar 20 '13 at 08:18
  • @Vini did you mean that you are not getting session stored values – codefreaK Dec 24 '14 at 15:39