File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Please help" Watch "Please help" New topic

Please help

Meng Tan
Ranch Hand

Joined: Jan 20, 2001
Posts: 115
I have 2 questions to ask :
1. Is there any method in the Servlet API (or anywhere) that can be used to decode a URL? That is, to replace the %XX symbol with ASCII characters.
2. Can we use HttpServletResponse.encodeURL() and HttpServletResponse.encodeRedirectURL() interchangeably? For example, Can I have a HTML tag printed like this
out.println("<a href=" + encodeRedirectURL(myURL) + ">click here</a>");
Please help.
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
I have an answer to your first question but not your second.
There is a class called URLDecoder in the Java2 SE. It has a static method called decode that takes a String (the url) and returns the decoded string. You can check out the Java 2 API here.

Matthew Phillips
Sun Certified Programmer for Java 2 Platform

Matthew Phillips
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
If your query string actually contains name=value pairs, you may rather use the getParameter methods on the request object.
For instance, request.getParameterMap() returns the map of requested parameters.
Beno�t d'Oncieu
Sun Certified Programmer for the Java� 2 Platform
I agree. Here's the link:
subject: Please help
It's not a secret anymore!