File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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: 17257

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

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: as it happens in ASP
It's not a secret anymore!