wood burning stoves 2.0*
The moose likes Struts and the fly likes how to change the URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to change the URL" Watch "how to change the URL" New topic
Author

how to change the URL

ram gaurav
Ranch Hand

Joined: Mar 29, 2006
Posts: 208
Hello

I am using struts in one of my application , everything is going out fine but when i submit the form then it will be redirected to Second page.

after submit
a.jsp -------------->>> b.jsp

Now what i see in URL is http://localhost:8080/testing/abc.do , but the page which is actually opened is a JSP page and i want that it will show by its original name in URL like: http://localhost:8080/testing/b.jsp but not as http://localhost:8080/testing/abc.do.

Please tell me what to do out for this.

Thanks
Regards
Gaurav
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you really want to do this, just specify redirect="true" when you define the forward to b.jsp in the struts-config.xml file.

However, there are some really good reasons for not doing this. The first one is that if you do this, anything you put in the request object will be lost. Anything you want passed on to the JSP will have to be either passed as a parameter in the URL, or put in the session. The second one is... well, here's an example:

Suppose that abc.do retrieves data from the database before displaying b.jsp, and that if you try to display b.jsp without hitting the abc action first, the page will throw exceptions. Then suppose the user bookmarks the page with the url of http://localhost:8080/testing/b.jsp. What's going to happen? You got it... exceptions.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to change the URL
 
Similar Threads
session invalidate?
Session persist when server shuts down?
URL same
struts application not using *.do
running tomcat