Reputation: 556
HTML Page
<form action="viewParticularImage.jsp" method="post">
input type="submit" name="1" value="Details" />
input type="submit" name="2" value="Details" />
input type="submit" name="3" value="Details" />
</from>
JSP page
<%
String name = request.getParameter("name");
out.write(name);
%>
i am getting null value
in name
while printing the button Details
in JSP Page pls help to find the solution, thanks to the replies in advance .
Upvotes: 0
Views: 2989
Reputation: 243
I believe you haven't gained any knowledge regarding HTML ... First, go and check the tutorials regarding HTML...
Let's get to the game ... What are you trying to do ... Are you trying to pull down values set to the submit button ... or you are trying to publish a textfield where user can type their name and show that name as the result in the next page ????
If you are trying to publish the values assigned to the submit button...
HTML Page
<form action="viewParticularImage.jsp" method="post">
<input type="submit" name="1" value="Details" />
<input type="submit" name="2" value="Details" />
<input type="submit" name="3" value="Details" />
</form>
JSP page
<%
String name = request.getParameter("1");
out.write(name);
%>
If you are trying to publish what users type ...
HTML Page
<form action="viewParticularImage.jsp" method="post">
<input type="text" name="name" />
<input type="submit" value="Hit Send" />
</form>
JSP page
<%
String name = request.getParameter("name");
out.write(name);
%>
I think this clarifies you how things work !!!! Thank you ... peace !!!
Upvotes: 0
Reputation: 12880
You are not sending a parameter named name
in the request.That's why! To confirm, try
<%
String name = request.getParameter("1");
out.write(name);
%>
Your form should be like below. See the value of name
attribute of the input text. The name
attribute denotes the name of the request parameter
<form action="viewParticularImage.jsp" method="post">
First name: <input type="text" name="name"><br>
<input type="submit" value="Submit">
</form>
Note : Try entering a value in the text and submit. You will receive it in the server request
Upvotes: 0
Reputation: 401
In your JSP page make it
<%
String name = request.getParameter("1");
out.write(name);
%>
Upvotes: 0
Reputation: 4197
You have parameters named as "1", "2" and "3", but you have not parameter named as "name".
<form action="viewParticularImage.jsp" method="post">
<input type="submit" name="name" value="Details" />
...
</from>
Upvotes: 1