?
Solved

JSP, Servlets and links

Posted on 2003-03-04
7
Medium Priority
?
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 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