my dog learned polymorphism*
The moose likes Servlets and the fly likes as it happens in ASP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "as it happens in ASP" Watch "as it happens in ASP" New topic

as it happens in ASP

Aqeel Ahmad

Joined: Sep 23, 2000
Posts: 11
I have been working with ASP, and now learning JSP. I could not find alternative methods as in ASP:
<em>Server.URLEncode</em> and

Kavita Ghia
Ranch Hand

Joined: Oct 10, 2000
Posts: 91
The foolowing code is an implementation of the HTMLEncode function that ASP has:

Hope this helps.
[This message has been edited by Frank Carver (edited November 29, 2000).]
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
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).]

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
For interest there is another implementation of this same function in another thread here.
Nitin Dubey
Ranch Hand

Joined: Oct 30, 2000
Posts: 126

I can find all the special characters taken care of. But m not sure that is this list complete ??
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019

That's doing it the hard way! Sun already provides a URLEncode method.
for an HttpServletResponse object, invoke:
String encodedURL = response.encodeURL( originalURL );

Customer surveys are for companies who didn't pay proper attention to begin with.
It is sorta covered in the JavaRanch Style Guide.
subject: as it happens in ASP