• Post Reply Bookmark Topic Watch Topic
  • New Topic

passing values from jsp to jsp : truncated  RSS feed

 
Priya Singh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me fidn out the solution to this prob..

i have to pass this string from jsp to jsp and its truncated at "#" .. is there any way i can pass the string in one variable ..

passing the string �'RULE-FILE-TEXT WEBWB HTMLDESIGNGRID!JS #20050324T150703.263 GMT'

From jsp to jsp truncates at char �#� and results in �'RULE-FILE-TEXT WEBWB HTMLDESIGNGRID!JS.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you are trying to pass it as a querystring parameter.
If so, you can use the response.encodeURL method to escape all the control characters.

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletResponse.html #encodeURL(java.lang.String)
 
Priya Singh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ...
call.jsp:

<a href="History.jsp?key=RULE-FILE-TEXT WEBWB HTMLDESIGNGRID!JS #20050324T150703.263 GMT" > click </a>

History.jsp:

key = (String) request.getParameter("key");

how to use encoder in this scenario
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben, according to the encodeURL description, it is only used for the URL rewriting method of session control, not to escape characters.

Personally I use org.apache.commons.lang.StringEscapeUtils.escapeHtml() from jakarta's commons-lang 2.0 library.

http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html

in your case, you need to escape the key value in the link:

<a href="History.jsp?key=<%=StringEscapeUtils.escapeHtml("RULE-FILE-TEXT WEBWB HTMLDESIGNGRID!JS #20050324T150703.263 GMT")%>" > click </a>
[ March 31, 2005: Message edited by: Yuriy Zilbergleyt ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!