Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Encoding URL path.

 
Tejas Aryan
Greenhorn
Posts: 22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a URL in form http://localhost:8080/custserver/customer/{custId}
The custId I receive can have any characters. It could be cust#101, cust/101, cust@mail.com etc.

If I encode the URL on client side, the other url delimiters are encoded. The other option is to extract the custId part and encode and append again to URL and send to server. On the server side, I decode it again to get the original custId. Is there a way where I can avoid this explicit encoding/decoding. ?
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please explain your requirement clearly

do you want URL encoding OR you do not want URL encding ?

~ abhay
 
Tejas Aryan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the encoding scheme but I should not do it explicitly everywhere in my application. It should be somewhat like declaring char-encoding in Connector element of tam server.xml file.
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think other option can be to use Servlet Filters.

You can catch all your incoming requests in Filter and then perform URL encoding with required character coding scheme. after that request will contine to go forward to required servlet/action/controller class.
in this way, all your encoding stuff is at one place in your application
~ abhay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic