• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Change double encoding of slash (+back) in param of request in Tomcat 8?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to change double encoding (to single) of slash and backSlash in parameter of request in Tomcat 8? While URL rewriting Tomcat makes excess step.
I have found useful article (it uses Apache):
http://tkurek.blogspot.ru/2013/06/252f-instead-of-2f-in-url-apache.html
and it seems that it can be useful (equivalent) for Tomcat. But i need to know where i should add such rules and how to work with backSlash.
 
Saloon Keeper
Posts: 23272
158
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Orlando!

URLs should not contain backslash characters. They should be using "real" (forward) slash characters. Maybe if you provided some examples of what kind of URLs you are trying to craft it would help.
 
Orlando Iks
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply.
I have slash(+back) (encoded) in request parameter.
Examples:


Tomcat don't understand not encoded slash (+back), but if they encoded Tomcat make encoding one more (excess) time - that's a problem
 
Tim Holloway
Saloon Keeper
Posts: 23272
158
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It isn't just Tomcat that can't understand. Our message editor seems to hate that sort of thing as well.

Can you try it again using Code tags? There's a button on the message editor that will insert special markup directives that you can wrap around your sample URLs and hopefully keep them from being mangled.
 
Orlando Iks
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. Edited previous post.
 
Marshal
Posts: 26385
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to encode the parentheses and the apostrophes, too, don't you?
 
Tim Holloway
Saloon Keeper
Posts: 23272
158
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is a really unfriendly URL syntax. It violates several principles defined in the RFCs that determine what the recommended structure of a URL should look like. And consequently, the normal web parsing services cannot help in decoding it. It isn't just Tomcat that would be offended.

A more compliant URL would be in the form:


Which would be trivial for both user-defined code and web service libraries to handle.

As it is, you're going to have to dissect the bogus "function call" syntax all on your own, which makes for more work on your part, higher app maintenance costs and less efficiency overall.

Your best bet is not to expect Tomcat to rewrite this stuff and simply have the app handle it while it's slogging through all the other one-off stuff. In conformance with the RFC-defined standards for URL transmission encoding, the URL that the web application sees would be decoded to:


And NOTE that a data backslash is simply one backslash, but if you compare against it using a string constant, that constant will need to be coded with a double-backslash in order to generate the single-backslash in the constant's actual value. There's a reason why backslashes are not popular outside of the shrinking world that encompasses Microsoft Windows.

You can obviously translate the second URL into the first using a simple String.replace() method call in your application code.

If you really do feel obliged to make the translation externally, you're probably better off fronting Tomcat with Apache and mod_rewrite.
 
Tim Holloway
Saloon Keeper
Posts: 23272
158
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:You have to encode the parentheses and the apostrophes, too, don't you?



Yes, best practice would be: https://tools.ietf.org/html/rfc3986#section-2.2

In actuality, I'm pretty sure that at this particular location in a URL, that there would be no conflict if you didn't, though.
 
Grow a forest with seedballs and this 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
reply
    Bookmark Topic Watch Topic
  • New Topic