Passing a URL through a URL in JSP

I'm trying to pass a URL to another URL in JSP.

someething like:

 <a href="http://www.mysite.com/?followOnUrl=<c:out value="${myForm.followOnURL} />"> Click for Link </a>


How do i make sure that the c:out data is escaped properly since it contains url.  I don't want my first page to misinterpret the followOnUrl variable.

Example?
tmonteitAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
enachemcConnect With a Mentor Commented:
use URLEncoder.encodeURL()
0
 
rrzConnect With a Mentor Commented:
I agree with  enachemc.  The solution looks something like this.
<%@ page import="java.net.URLEncoder"%>
<a href="http://www.mysite.com/?followOnUrl=<%=URLEncoder.encode(myForm.getFollowOnURL(),"UTF-8")%> />"> Click for Link </a>    
0
 
tmonteitAuthor Commented:
Nice....

solution to enachemc

Points to rrz@871311  for the example.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.