Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirect one url to another.

 
clay jay
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say someone enters index.html or index.htm I want them to be redirected to index.jsp. I see I can make a simple redirector servlet and then have a servlet mapping in my web.xml but I would imagine there is a simpler way to do this. Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64856
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Of course, will only work is script is not disabled.
 
clay jay
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may sound completely stupid but do you mean just create fake/blank index.html and index.htm pages and just simply have them redirect if they are ever hit?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64856
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, you asked for simple.

Otherwise, I'd use the mapping technique in the deployment descriptor to define the URLs to where you want them to go.
 
clay jay
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks Bear, that method just caught me a little off guard so I thought I might be completely misunderstanding you and just to make sure when you refer to the mapping technique in the deployment descriptor you are referring to what I described in post 1. Like there is no simple way I'm missing to map one url to another from inside the web.xml.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic