File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes problem in retrieving the parameters through request.getParameter() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem in retrieving the parameters through request.getParameter() " Watch "problem in retrieving the parameters through request.getParameter() " New topic
Author

problem in retrieving the parameters through request.getParameter()

neha agrawal
Greenhorn

Joined: Mar 30, 2006
Posts: 4
how do i retrieve the parameters through request.getParameter() when the URL passed to the servlet is encoded by java.net.URLEncoder.encode() method?

Below is the code in aj sp page:
String dblink = java.net.URLEncoder.encode
("/TCE/servlet/LoginService?name="+vSystemAccount.getAccountName()+"&password="+pw2,"UTF-8");
RequestDispatcher dispatcher = request.getRequestDispatcher(dblink);
dispatcher.forward(request,response);

The code in the servlet LoginService is:
public void processRequest(HttpServletRequest request,
HttpServletResponse response)
{
String userName = request.getParameter("name");

String userPassword =request.getParameter("password");
.......
}
Here in the method processRequest i want to decode the URL by java.net.URLDecoder.decode method,but after that how do i extract the parameters ?
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

I am not sure you can add parameters to the request while forwarding. A better approach would be to add request attributes and retrieve them in the forwarded resource.

ram.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
Hi,

Try to replace + with "%somenumber" I do not remember exact number but %24 give us$,try to find by replacing this number in query string

-Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in retrieving the parameters through request.getParameter()