Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how to change the URL

 
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
 
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.
 
That is a really big piece of pie for such a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic