Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

JSP, Servlets and links

Posted on 2003-03-04
7
Medium Priority
?
209 Views
Last Modified: 2012-05-04
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?
0
Comment
Question by:Cmdr_Raptor
  • 3
  • 3
7 Comments
 
LVL 4

Accepted Solution

by:
thanassis earned 140 total points
ID: 8063621
<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
 
LVL 1

Expert Comment

by:umangjoshi
ID: 8063709
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
 

Author Comment

by:Cmdr_Raptor
ID: 8063852
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Cmdr_Raptor
ID: 8063990
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
 
LVL 4

Expert Comment

by:thanassis
ID: 8063993
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
 
LVL 4

Expert Comment

by:thanassis
ID: 8064004
Yes, every link different function
0
 

Author Comment

by:Cmdr_Raptor
ID: 8064041
Created a go1(), go2() etc function for every link. Got it working now. Tnx :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, technologies make investments easier and it's not even necessary to look for investors in some cases. In this article, we will consider Initial Coin Offering (ICO) investment scheme.
I’m willing to make a bet that your organization stores sensitive data in your Windows File Servers; files and folders that you really don’t want making it into the wrong hands.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question