Vini
Vini

Reputation: 119

URL do not change even after request dispatching in servlet

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);
          }

Upvotes: 1

Views: 4160

Answers (1)

Ravindra Gullapalli
Ravindra Gullapalli

Reputation: 9168

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)

Upvotes: 5

Related Questions