• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Empty URL redirection issue in jsp

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to redirect http://mywebsite.com/?bannerId=12332 to a specific jsp

For that I created a url pattern as
<servlet>
<servlet-name>lostdocsJSP</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>lostdocsJSP</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

It is redirecting above URL to index.jsp , but all other requests for images, swf, xml also getting redirected to this JSP , How can I avoid this issue in WAS 6.1
I know that in Tomcat I can define a default URL pattern to bypass any unwanted requests, but it is not working in Webshpere.

Tomacat :
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>.jpg</url-pattern>
</servlet-mapping>
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you need to change url-pattern.
<url-pattern>/*</url-pattern> will forward all requests to jsp, change it accordingly.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course if you tell it to send all requests to that JSP, it will!

What are you really trying to accomplish?
 
Ratheesh Kamoor
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If any one typed as http://mysite.com/?bannerId=1234 , then this request should go to index.jsp. I dont want any other request to go to index.jsp
How can I achieve that.
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ratheesh Kamoor:
If any one typed as http://mysite.com/?bannerId=1234 , then this request should go to index.jsp. I dont want any other request to go to index.jsp
How can I achieve that.



Just set the welcome page to index.jsp. It should work. Something likes


[ November 27, 2008: Message edited by: Duc Vo ]
[ November 27, 2008: Message edited by: Duc Vo ]
 
Ratheesh Kamoor
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Duc Vo, I know that I can use welcome file . But when I use this option I am loosing query strings (Eg: bannerId = 123) when i read it from index.jsp.. What should I do to retain all query strings as it is ?
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ratheesh Kamoor:
Thanks Duc Vo, I know that I can use welcome file . But when I use this option I am loosing query strings (Eg: bannerId = 123) when i read it from index.jsp.. What should I do to retain all query strings as it is ?



Ah, you shouldn't use query string. Should use request.getParameter(). I.e.

String bannerId = request.getParameter("bannerId");

Then it should work.
[ November 27, 2008: Message edited by: Duc Vo ]
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ratheesh Kamoor:
But when I use this option I am loosing query strings (Eg: bannerId = 123) when i read it from index.jsp.. What should I do to retain all query strings as it is ?



can you give some more details?

i guess , before index.jsp, you want to do some logic in servlet and then you want to pass the parameter to the index.jsp right? if yes,

then choose some particular servlet instead of /* .
 
Ratheesh Kamoor
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, getProperty is working as expected
Thanks again
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic