This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in retrieving the parameters through request.getParameter()

 
neha agrawal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic