Usually when we try to get text field parameters we write the code as
String name = request.getParameter("parameter-name");
I am trying to select an image from <input type="file">
tag and action performed on clicking submit button is page gets redirected to (from_encryption.jsp) page.
From that jsp page i need to get the image which i selected in the html page. I have tried to get the parameters using FileInputStream and BufferedImage,code given below. But it is returning "NULL" value. I am trying to retrieve the image so that i can perform encryption operations. My requirement is not for image uploading. Can anyone tell me how to get the image from the html to jsp page.
HTML code
<form action="from_encryption.jsp">
<table>
<tr>
<td></td>
<td><input type="file" name="Choose1" accept="image/*"></td>
</tr>
</table>
<br><br><input type="submit" name="encrypt" value="ENCRYPT">
</form>
JSP page(from_encryption.jsp)
try
{
FileInputStream fis = new FileInputStream(request.getParameter("choose1"));
BufferedImage image = ImageIO.read(fis);
int height = image.getHeight();
int width = image.getWidth();
out.print(height+","+width);
}
catch(Exception e)
{
out.print(e.getMessage());
}