0

I have two jsp page, in first page i write html code. in html i have on form in which two textbox and one file upload control and submit button.

now, when i click on submit button then i want to get whole form data (textbox data and file path) in second jsp page.

In second jsp page i write code of file uploading.

My problem is i didn't get both data in second jsp page. i got either textbox data or file. but i want both at a time.

so please help me. Thanks.



  • You can start with this: http://stackoverflow.com/questions/19510656/how-to-upload-files-on-server-folder-using-jsp – Mosh Feu Oct 14 '15 at 07:00

2 Answers2

0

Suppose you Defined myFile name as a private and apply setter and getter method on variable. that will give you a file name what ever you have upload it from upload control .

  • use taglib for get property Name in JSP Code .

    private File myFile;   //give file name 
    private String TextValue;  // give text field value 
    public File getMyFile() {
    return myFile;
    }
    
    public void setMyFile(File myFile) {
    this.myFile = myFile;
    }
    
    public String getTextValue() {
    return TextValuee;
    }
    
    public void setTextValue(String TextValue) {
    this.TextValue = TextValue;
    }
    

then go JSP and Define taglib and value using property Name Code :-

 <%@ page contentType="text/html; charset=UTF-8" %>
 <%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>File Upload Success</title>
</head>
<body>
You have successfully uploaded <s:property value="<s:property value="Myfile"/>"/>
with TextBox <s:property value="<s:property value="TextValue"/>"/>
</body>
</html>
Siboo
  • 61
  • 8
0

try like this

first.jsp

<form action='secondjsp.jsp' method='post' enctype='multipart/form-data'>
<input type='textbox' name="textbox"/>
<input type='submit' value='submit' />
</form>

second.jsp

<%
String file = request.getParameter('textbox');
%>
Vishnu Katpure
  • 293
  • 3
  • 15