JSP to reference anchor tag

Hello,
This is a pretty easy question for anyone who knows the answer.  Basically, I'm building an web page using JSP.  An anchor is set at the top of the page and I need to change what that is pointing to (href) based on a variable at the bottom of the program.  How do I use jsp to reference an anchor tag that's located elsewhere in the program?

Thanks!

John
jlm151Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gagaliyaCommented:
not clear what you mean exactly. but you cannot directly do it in 1 jsp using java as html are generated sequentially on serverside and once generated cannot be changed by serverside jsp. Two options

option 1) have two jsp, passing the variable from one to another using form.  something like:

jspone:
<html><head></head><body>Loading please wait....
.....
<%String your_variable="somevalue";%>

<script type="text/javascript">
document.testform.action="jsptwo.jsp?variabletopass=<%=your_variable%>";
document.testform.submit();
</script>
<form method="get" id="testform">  
........
</form>
</body></html>

jsptwo: this is your real jsp that is shown to the user
.......
<a href="<%=request.getParameter("variabletopass")%>">anchor or whatever </a>
...........
---------------------------

option2) use javascript, set one of the javascript variable to a jsp/java variable at the bottom of your jsp. then you can use javascript to manipulate what the html is pointing to on the client side.

gaga
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jlm151Author Commented:
That worked!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

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.