Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

as it happens in ASP

 
Aqeel Ahmad
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been working with ASP, and now learning JSP. I could not find alternative methods as in ASP:
<em>Server.URLEncode</em> and
<em>Server.HTMLEncode</em>
Thanks
 
Kavita Ghia
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The foolowing code is an implementation of the HTMLEncode function that ASP has:

Hope this helps.
Regards,
Kavita.
[This message has been edited by Frank Carver (edited November 29, 2000).]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two things to note when posting code to this board:
1. Please put UBB CODE tags round your code to preserve the formatting.
2. If you use HTML escape sequences in your code such as > they will be converted to the equivalent characters when the page is shown, which will probably mystify readers. To force the board to show &gt; you need to type &amp;gt;.
I have edited the above example to do this, but everyone should really be aware of these issues when posting code.
[This message has been edited by Frank Carver (edited November 29, 2000).]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For interest there is another implementation of this same function in another thread here.
 
Nitin Dubey
Ranch Hand
Posts: 126
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I can find all the special characters taken care of. But m not sure that is this list complete ??
Regards,
nitin
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18009
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's doing it the hard way! Sun already provides a URLEncode method.
for an HttpServletResponse object, invoke:
String encodedURL = response.encodeURL( originalURL );
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic