• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher behaving strangely with encoding

 
Rajul Konkar
Greenhorn
Posts: 20
Android Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem statement : request.getDispatcher() encodes queryString given in targeturl

Code:


now here lRequestDispatcher contains :

it gives wrong created_date in request parameter/attribute

what is the encoding done here and why & by whom ?


Thanks in advance
Rajul konkar
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2419
95
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajul,

How are you getting the value of the queryString?

Frits
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Rajul Konkar
Greenhorn
Posts: 20
Android Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Ben & Frits

Firts : getting the value of the queryString? : can be done though inspection of the RequestDispatcher object.

Ben : with server side forwards it is better (and easier).
But according to project requirements
I need to pass the target-URL as a whole String in request.getRequestDispatcher(target-URL).
so cannot individually set the required value as attribute in request.

I want to understand why the string is encoded as Shown,
What is ideal behavior of request Dispatcher.

Thanks

 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2419
95
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajul,

Do you have a problem forwarding or just with the fact that when you look at the String in the RequestDispatcher that it is encoded differently?
If you request the queryString in the target server how does it look like then?

Regards,
Frits
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got control characters in your string.
The ouput from this code


is:
Date: 2010\:4\:22\:12\:15\:42
Enc Date: 2010%5C%3A4%5C%3A22%5C%3A12%5C%3A15%5C%3A42
 
Rajul Konkar
Greenhorn
Posts: 20
Android Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ,

I think I understood the problem.
I cannot use \ as a escape character in the value of request attribute,

I'll need to restructure the attribute passing mechanism.

Rajul Konkar

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that was not the problem.

You need to URL Encode your strings before adding them to the querystring.
There are other characters in there that need to be encoded.

 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic