This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 613
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 !!!
 
wood burning stoves
 
subject: problem in retrieving the parameters through request.getParameter()
 
Similar Threads
data grid with edit and delete options
how to pass a parameter in the query string with the '+' sign in it unchanged.
Frameworks? Do I need one? want one?
how to call JSP from Servlet
how to pass a parameter in the query string with the '+' sign in it unchanged.