• 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

Proper use of URL rewriter (tuckey)

 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is going to be long, kindly bear with me.

My question is whether there is any easier way to achieve the following.
And my doubt is when redirection happens in default handler, jsessionid is being appended in URL automatically, why is this happening?

I have a spring MVC application deployed in tomcat. Application is deployed as ROOT and URL is http://<ip>:8080/
Requirement: URL should be like http://<ip>:8080/us/en/mainapp/mobile-application
Then subsequent requests from browser should go as
http://<ip>:8080/us/en/mainapp/mobile-application/getReport
http://<ip>:8080/us/en/mainapp/mobile-application/getUserData

After creating rules in urlrewrite.xml, problem was whenever I hit http://<ip>:8080/us/en/mainapp/mobile-application
subsequent requests from browser went like http://<ip>:8080/us/en/mainapp/getReport (wrong)
I found that when I hit http://<ip>:8080/us/en/mainapp/mobile-application/ ("/" appended)
subsequent requests went like http://<ip>:8080/us/en/mainapp/mobile-application/getReport (right)

So I added a default handler in Controller and "Rule 1" in urlrewriter to pass the request first to the default handler, then appending a "/" and redirecting it to actual handler.
It did the trick, but it is not looking good. Is there any better way to so this?
And why jsessionid is being appended in URL when redirection happens in default handler, but not when request directly comes to the other handler.
I am posting relevant parts of the code below

 
Ranch Hand
Posts: 56
4
Mac OS X IntelliJ IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also once fought with tucket url rewriter, so I know how time consuming it can be to set up these rules.
Actually rewriting urls is VERY simple, so I have an alternative route for you to go without tuckey:

1. For the request mapping, write a javax.servlet.Filter that rewrites the incoming request to the real request
2. Declare your filter in web.xml
3. For the response mapping from the real response to the rewritten response,
extend the class javax.servlet.http.HttpServletResponseWrapper;

 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic