JSP, Servlets and links

On a JSP website I'm developing, I got code looking like this:

<form method='post' action='../servlet/NavigasjonServlet' target="main">
<input type='hidden' name='doThis' value='start' />
<input type="submit" value="Hjem" />
</form>

This is one of several buttons on a menu. So depending on what value this button has, the servlet (NavigasjonServlet) find the proper .jsp page yo display in the i Frame (target="main").

How can I make the servlet still decide what page to display, but by using links instead og buttons?
Cmdr_RaptorAsked:
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.

thanassisCommented:
<script language="javascript">
<!--
  function go() {
    document.form1.submit();
    return true;
  }
//-->
</script>


<form method='post' name = 'form1' action='../servlet/NavigasjonServlet' target="main">
<input type='hidden' name='doThis' value='start' />
</form>

<a href="#" onClick="go()">Go back <img src="...">go</a>
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
umangjoshiCommented:
pls check it:
-------------

<head>
<script language="JavaScript">
function call1(f)
{
   f.action = 'path of jsp1 or servlet1';
   f.submit();
}

function call2(f)
{
   f.action = 'path of jsp2 or servlet2';
   f.submit();  
}
</script>
</head>
<body>
<form name="f" method="post" action="../servlet/NavigasjonServlet' target="main">

<input type="button" onClick="call1(f)" value="Add">
<input type="button" onClick="call2(f)" value="Edit">
</form>
0
Cmdr_RaptorAuthor Commented:
thanassis : I can't seem to get that to work. Could you describe it abit more?

umangjoshi : I was trying to avoid using buttons...
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Cmdr_RaptorAuthor Commented:
thanassis : My bad. I got it to work on one link now. However, the moment I create a second link, there is created an error. Is it nessecary to make one function for each link?
0
thanassisCommented:
Write:
<a href="#" onClick="go()"><img src="..."></a>
instead of:
<a href="#" onClick="go()">Go back <img src="...">go</a>

Did you give a name to your form e.g "form1"?

<form method='post' name = 'form1' action='../servlet/NavigasjonServlet' target="main">

what was your problem, explain a little
0
thanassisCommented:
Yes, every link different function
0
Cmdr_RaptorAuthor Commented:
Created a go1(), go2() etc function for every link. Got it working now. Tnx :)
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.