• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Browser Path Not Refreshing

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have an application where the first page is the jsp page which asks the user to keyin username and password.

Once the user clicks on Login the control is shifted back to the servlet.
The servlet invokes the EJBs and gets whether the userlogin is successful or not.

The URL mapping for the servlet is /login.do.

If the user keys in the this path http://localhost:7001/JJWeb/login.do then the doGet method of my servlet will be called where i redirect the user to go back to the login page using the request dispatcher.

Till this everything works but there is a problem when the forward is called.

In the browser address bar the address is http://localhost:7001/JJWeb/login.do and not http://localhost:7001/JJWeb/index.jsp.


I am hereby attaching the servlet/jsp and web.xml.





<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<description>Handles the login</description>
<display-name>JJ Login Servlet</display-name>
<servlet-name>JJLoginServlet</servlet-name>
<servlet-class>
com.mumz.jennyjaisy.login.JJLoginServlet
</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>JJLoginServlet</servlet-name>
<url-pattern>/doLogin.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Prabhat Jha:
Till this everything works but there is a problem when the forward is called.


That's not a problem; that's the way things work.

The forward happens on the server. How is the browser supposed to know about it and update the address bar?

If you want the browser to get involved, use a redirect in place of the forward.

But first and foremost, why do you care?
 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply i dont want the user to even see that there is something called as login.do thats why wanted to refresh the browser.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you might want to investigate the PRG (Post-Redirect-Get) pattern.
reply
    Bookmark Topic Watch Topic
  • New Topic