aspose file tools*
The moose likes Servlets and the fly likes Encoding URL path. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Encoding URL path." Watch "Encoding URL path." New topic
Author

Encoding URL path.

Tejas Aryan
Greenhorn

Joined: Apr 12, 2009
Posts: 22
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

Joined: Feb 29, 2008
Posts: 1162
    
    1

please explain your requirement clearly

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

~ abhay


Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
Tejas Aryan
Greenhorn

Joined: Apr 12, 2009
Posts: 22
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

Joined: Feb 29, 2008
Posts: 1162
    
    1

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Encoding URL path.