File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to change the URL" Watch "how to change the URL" New topic

how to change the URL

ram gaurav
Ranch Hand

Joined: Mar 29, 2006
Posts: 208

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/ , 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/

Please tell me what to do out for this.

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 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.

Consultant, Sima Solutions
I agree. Here's the link:
subject: how to change the URL
It's not a secret anymore!