How to retrieve text box value from a JSP page
Solution 1
Put the following code between form tag.
<form ENCTYPE="multipart/form-data" ACTION="upload.jsp" METHOD=POST>
<center>
<label for="email">Enter email address</label>
<input id="email" name="email">
</center>
-------
-------
</form>
on Server side write
String email=request.getParameter("email");
this will definitely solved your problem.
Solution 2
you are requesting for upload.jsp?e=<%=mail%>
where the parameter name is e
and an other side you are getting the request.getParameter("email");
try this request.getParameter("e");
or use this instead upload.jsp?email=<%=mail%>
for request.getParameter("email");
user3254893
Updated on February 05, 2020Comments
-
user3254893 about 4 years
I am creating a web application in Java and am having trouble retrieving a value from a text box. My aim is to ask the user to enter their email address and then use the value entered for the rest of my application. I do this by attempting to pass the value as part of the URL in the jsp file (and retrieve it using request.getParameter()). However, the value that I keep retrieving is null.
Here is my code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD> <TITLE>Display file upload form to the user</TITLE> </HEAD> <center> <label for="email">Enter email address</label> <input id="email" name="email"> </center> <% String mail = request.getParameter("email"); System.out.println(mail);%> <BODY> <FORM ENCTYPE="multipart/form-data" ACTION="upload.jsp?e=<%=mail%>" METHOD=POST> <br> <br> <br> <center> <table border="0" bgcolor=#ccFDDEE> <tr> <center> <td colspan="2" align="center"><B>UPLOAD THE FILE</B> <center></td> </tr> <tr> <td colspan="2" align="center"></td> </tr> <tr> <td><b>Choose the WebEx File To Upload and Convert:</b></td> <td><INPUT NAME="file" TYPE="file"></td> </tr> <tr> <td colspan="2" align="center"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Upload and Convert Recording"></td> </tr> <table> </center> </FORM> </BODY> </HTML>
I am trying to pass the mail value into the jsp file so that I can use it in my application
-
hd1 about 10 yearsDo you not need a <form> tag?
-