title: Can we somehow change the url in addressbar after dispatching request from servlet to jsp
body: <p>I am having a weird problem here, and I am really stuck, need to get this work badly.</p>
  
  <p>so i have a page say index.jsp with a link say "a href=servlet?id=10". when I click on this link it will go to doGet() on my servlet and here is the code in my servlet.</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
                   String action = request.getParameter("id");
                    // search database and create an arraylist
                          if(//user logged in)
                          address = "s/results.jsp";
                          else   
                          address = "results.jsp";
                     // set arraylist in session object
                  RequestDispatcher dispatcher = request.getRequestDispatcher(address);
                  dispatcher.forward(request,response);
       }
  </code></pre>
  
  <p>So the above code works fine but after request forwarding, my browser shows the url as</p>
  
  <p><a href="http://localhost/project/servlet?id=10" rel="nofollow">http://localhost/project/servlet?id=10</a>. </p>
  
  <p>I don't want the above url as i am forwarding to two different jsp's based on the user login status one is in 's' folder and other is outside of that.
  if user is logged in then i forward to 's/results.jsp' and if user is not logged in i am forwarding to 'results.jsp'.</p>
  
  <p>in case of s/results.jsp i am accessing resources like images and scripts from outside of 's' folder by using ../ in the results.jsp.</p>
  
  <p>as url is not changing to s/results.jsp , i am unable to access the resources with '../'
  and as i am using jsp pagination , when i click next the url is changing to s/results.jsp
  and in that case i am able to access resources using ../</p>
  
  <p>one solution in my mind is to copy all resources in s folder , but that would increase 
  redundancy.</p>
  
  <p>one other solution in my mind is to create two different servlets for two jsp's 
  but i don't know where to put the  servlet so that it can access resources outside of s folder with ../</p>
  
  <p>is their any other good way i can do the task..</p>
  
  <p>I have tried to find information about this but haven't been able to figure it out.</p>
  
  <p>Any help will be very much appreciated.</p>