Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to change the URL

 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic