Null values in request.getParameter in JSP

I am new with HTML / jsp programming and have an issue where I am not getting the values in jsp2 using request.getParameter (null), from the html of jsp1.

Jsp1
From a html table in jsp1,   one posible function is to make a selection from a drop down list (AD1), enter a search value in a text box (searchtext) and then hit the Search button  this launches jsp2.

Jsp2
Get the values of the drop down selection and search text value and work logic in jsp2 based on those values  such as setting session attributes and then calling another jsp (which could possibly be jsp1 again).

The values of the 2 getParameter variables in jsp2 (that are set in jsp1) are null.

I have attached some code snippets  can anyone point out what I am doing wrong?

Thanks!

Jsp1
 
<form method="post">					
 
<TABLE border="0" width="75%" height="3%">
<TBODY>
<TR>
							
<TD width="9%" height="19" align="center" valign="middle"><B>
<FONT color="#000099"><%= searchDescription %></FONT></B></TD>
							
<% if (language == "F") { %>
<TD width="12%" height="19" valign="middle" align="center">	
<p> <input <select size="1" name="AD1" id="AD1" style="font-weight: bold">
<option selected value="4">NCP</option>
<option value="1">Ville</option>
<option value="2">Compagnie</option>
<option value="5">Code postal</option>
<option value="3">Personne-ressource</option>
</select> > </p> 	 
</TD>
							
<% }
else { %>
<TD width="12%" height="19" valign="middle" align="center">
<p> <select size="1" name="AD1" id="AD1" style="font-weight: bold">
<option selected value="4">Fleet Account</option>
<option value="1">City</option>
<option value="2">Company</option>
<option value="5">Postal Code</option>
<option value="3">Key Contact (By First Name)</option>
</select> </p>
</TD>						
<% } %>	
					
<TD width="13%" height="19" align="center" valign="middle">
<INPUT type="text" name="searchtext" size="25" maxlength="25"></TD>							
<% if (language == "F") { %>
<TD width="8%" height="19" align="left" valign="middle">
<IMG
border="0" src="../images/dcsearchfr.gif" width="75" height="32"
onClick="parent.location='/FleetBlitz/jsp/jsp2.jsp'"></TD>
 
<% }
else { %>
<TD width="8%" height="19" align="left" valign="middle">
<IMG
border="0" src="../images/dcsearch.jpg" width="82" height="25"
onClick="parent.location='/FleetBlitz/jsp/jsp2.jsp'"></TD> 	
<% } %>	
 
<TD width="33%" height="19" align="center"></TD>
 
</TR>
</TBODY>
</TABLE>
							
</form>
 
......
 
 
Jsp2
 
<%
 
String dropDownSelection = request.getParameter("AD1");
String searchText = request.getParameter("searchtext");
 
session.setAttribute("KeyField", searchText);
 
&..  more logic &.
 
%>

Open in new window

Al_SararasAsked:
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.

summerianCommented:
The line below:

<form method="post">                                    

will not direct your submit/request to jsp2, but to current page (jsp1). How do you get do jsp2 with this form?

0
summerianCommented:
If I get this right, you should correct it this way:

<form method="post" action="/path/to/jsp2.jsp">  
0
summerianCommented:
Oh, I get it:

Code below sets browser address to jsp2, but does not submit the form!

<IMG
border="0" src="../images/dcsearch.jpg" width="82" height="25"
onClick="parent.location='/FleetBlitz/jsp/jsp2.jsp'"></TD>      

change it to this:
<IMG
border="0" src="../images/dcsearch.jpg" width="82" height="25"
onClick="document.myform.submit()"></TD>  

and set id of the form to 'myform':

<form id="myform" method="post">
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Al_SararasAuthor Commented:
I was getting to jsp2 using onClick against the Search button
0
summerianCommented:
You must also supply the address where the browser should submit the form (if you use code in my previous post)
<form id="myform" method="post" action="/FleetBlitz/jsp/jsp2.jsp">
0
Al_SararasAuthor Commented:
I have changed my code to ...

<form id="myform" method="post" action="/FleetBlitz/jsp/jsp2.jsp">

<TD width="8%" height="19" align="left" valign="middle">
<IMG
border="0" src="../images/dcsearch.jpg" width="82" height="25"
onClick="document.myform.submit()"></TD>

When I click on the button jsp2 does not launch - I get an error - 'document.myform' is null or not an object.  
Any ideas?
0
cmalakarCommented:
you should also put nam="myform" in form tag.. ie.,

<form name="myform" id="myform" method="post" action="/FleetBlitz/jsp/jsp2.jsp">
0
summerianCommented:
Hmm.. Try this, should work:
<form id="myform" name="myform" method="post" action="/FleetBlitz/jsp/jsp2.jsp">
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
Al_SararasAuthor Commented:
Success!

Thanks for your help - very much appreciated!
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
Scripting Languages

From novice to tech pro — start learning today.