aspose file tools*
The moose likes JSP and the fly likes Escape characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Escape characters" Watch "Escape characters" New topic
Author

Escape characters

Ronwaldo Cruz
Ranch Hand

Joined: Oct 17, 2006
Posts: 69
Hi,

I have a piece of code in my JSP:

<%
String text = "#" ;
request.setAttribute("text", text);
%>
<%=text%>

Currently it displays as #. I need it to change to %23.

Also can I ask somebody to please differentiate escaping vs. encoding? Thank you very much
Charbel Keyrouz
Ranch Hand

Joined: Jun 10, 2005
Posts: 46
Encoding in your case is url encoding means replacing the spaces for example with %20.
The purpose of the encoding is the replacing of some character with their hex code so to make sure that the characters will be transmitted correctly as they are.

The escaping character allows the compiler to jump over the next character without checking it.
example:

if you want to go to another line in java you concatenate your string with \n.
So the \ character is a key to an action and once you have written \n the compiler will go to another line while executing.

so the \ is an escaping characher.
if you need to print the " symbol inside a string you say: String t = "i want to print the \" character as is.";
with the usage of the \ character the compiler will not consider the " as end of string but as a normal character that will be printed like any other one.

Hope I was clear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Escape characters