aspose file tools*
The moose likes JSP and the fly likes jsp parameters pass more than one value to the handler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp parameters pass more than one value to the handler" Watch "jsp parameters pass more than one value to the handler" New topic
Author

jsp parameters pass more than one value to the handler

Joyce Hughes
Greenhorn

Joined: Feb 24, 2007
Posts: 7
Hi, I have a jsp page that has three buttons that the user can click. The value is then passed to a javascript function where it sends it to a Request Handler. When I click on one, it still passes all three to the handler. Can someone look at my code and tell me what the problem is?

part of the code is below:

<%
final String buttonAction_AllPatients = "ALL PATIENTS";
final String buttonAction_MyPatients = "MY PATIENTS";
final String buttonAction_MyClinics = "MY CLINICS";
%>

<html>
<head>
<title>My Patients Admitted or Discharged within the Last 72 hours</title>
<script type="text/javascript" src="../js/common.js"></script>
<link rel="stylesheet" href="../stylesheets/main.css" type="text/css">
<script LANGUAGE="javascript" type="text/javascript">
function submit_onclick(action)
{
//alert("action="+action);
// VALIDATE SELECTIONS...
var ok = "YES";

if(action == "<%=buttonAction_AllPatients%>")
{
alert("actionpt="+ action);
var varr = "";
varrr = document.SETUICFORM.KEY_PATIENTSA.value;
alert("varrr="+varr);
document.SETUICFORM.submit();
}

else if(action == "<%=buttonAction_MyPatients%>")
{
alert("actionpt="+ action);
var varr = "";
varr = document.SETUICFORM.KEY_PATIENTSB.value;
alert("varr="+varr);
document.SETUICFORM.submit();
}

else if(action == "<%=buttonAction_MyClinics%>")
{
alert("actionpt="+ action);
var varr = "";
varr = document.SETUICFORM.KEY_PATIENTSC.value;
alert("varr="+varr);
document.SETUICFORM.submit();
}
else
{
ok = "NO";
alert("No button was clicked")
}
}
</script>
</head>

<%@ include file = "../provider/navigate.inc" %>

<body topmargin="0" leftmargin="0" bgcolor="white">

<div id="contentBox">
<table border="0" id="tblBody2" >
<tr class="white" >
<td class="tblcell14" nowrap><strong>Portal Views> My Admitted/Discharged Pts (within the last 72 Hours)</strong></td>
<td class="tblcellp" nowrap>Personal Data - Privacy Act of 1974 (PL 93-579)</td>
</tr>
<tr >
<td ></td>
</tr>
<%
// Retrieve the Data...
HospStay_72_Data viewData = ( HospStay_72_Data ) request.getAttribute( HttpKeys.KEY_CON_DATA );

String errorText = viewData.getErrorText();
if ( errorText != null ) {
%>
<tr >
<td >
<table border="0" id="tblBody1" >
<tr class="yellow10">
<td class="tblcellb" >
<strong>Please report the following error using the Feedback icon:


Error: Portal Views->My Admitted/Discharged Patients: </strong>

Error = <%= errorText %>
</td>
</tr>
</table>
</td>
</tr>
<%
}
else {
%>
<%
url = mWebAppName + "/control/hospitalstaybyuic";
%>

<form name="SETUICFORM" method="POST" action="<%= url %>">
<tr >
<td>
For ALL patients Admitted/Discharged within 72 hours, click
<input type="button" class="button" value="ALL PATIENTS" onClick="javascript:submit_onclick('<%= buttonAction_AllPatients %>')">

<input type="hidden" name="KEY_PATIENTSA" value="<%= buttonAction_AllPatients %>">

</td>
</tr>
<tr >
<td>
For MY patients Admitted/Discharged within 72 hours, click
<input type="button" class="button" value="MY PATIENTS" onClick="javascript:submit_onclick('<%= buttonAction_MyPatients %>')">

<input type="hidden" name="KEY_PATIENTSB" value="<%= buttonAction_MyPatients %>">
</td>
</tr>
<tr >
<td>
For patients in MY CLINIC Admitted/Discharged within 72 hours, click
<input type="button" class="button" value="MY CLINICS" onClick="javascript:submit_onclick('<%= buttonAction_MyClinics %>')">

<input type="hidden" name="KEY_PATIENTSC" value="<%= buttonAction_MyClinics %>">
</td>
</tr>
</form>
<tr >
<td ></td>
</tr>


The request handler then gets the values in this piece of code

String allPatients = request.getParameter("KEY_PATIENTSA");
String myPatients = request.getParameter("KEY_PATIENTSB");
String myClinics = request.getParameter("KEY_PATIENTSC");




Thank you for any help!


rejoyce
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Joyce Hughes wrote:Can someone look at my code and tell me what the problem is?

That's way too much unformatted code to look at.

Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Just guessing -- when a form is submitted, all inputs in the form are submitted.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp parameters pass more than one value to the handler