GeeCON Prague 2014*
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


JavaRanch » Java Forums » Java » Servlets
Bookmark "as it happens in ASP" Watch "as it happens in ASP" New topic
Author

as it happens in ASP

Aqeel Ahmad
Greenhorn

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
<em>Server.HTMLEncode</em>
Thanks


Aqeel
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.
Regards,
Kavita.
[This message has been edited by Frank Carver (edited November 29, 2000).]
Frank Carver
Sheriff

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 frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Frank Carver
Sheriff

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

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

Joined: Jun 25, 2001
Posts: 16095
    
  21

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.
 
Consider Paul's rocket mass heater.
 
subject: as it happens in ASP