Hai all,
while i try to upload image file to server i dont get the getParameter values of name1 and image1. Could any one tell me where can be my mistake. Upload of the image works fine.
regards
prabhakar.
My
Servlet Prog
~~~~~~~~~~~~~~~
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
import com.oreilly.servlet.*;
public class SaveImageFile extends HttpServlet
{
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
PrintWriter out=res.getWriter();
res.setContentType("text/html");
System.out.println("Name Received is:"+req.getParamete("name1"));
out.println("<html><body>");
try{
MultipartRequest m1=new MultipartRequest(req,"c:\\image");
String e1=m1.getParameter("image1");
System.out.println(" File Name :\t "+e1);
System.out.println("ContentType:\t"+m1.getContentType("image1"));
out.println("Execution successfull");
}
catch(Exception e){
out.println("<html><body>");
System.out.println(" Error :\t"+e);
out.println("Error during Processing");
out.println("</body></html>");
out.close();
}
out.println("</body></html>");
out.close();
}
}// End of SaveImageFile
My html file.
~~~~~~~~~~~~~
<html><head><title> Sample
testing</title></head>
<BODY BGCOLOR="#ccffcc">
<form ENCTYPE="multipart/form-data" action="http://202.141.81.233:8080/servlet/SaveImageFile" method="post">
<table>
<tr>
<td> Enter the name :
<input type="text" name="name1" size=10 ></td>
</tr>
<tr>
<td> Choose the image file
<input type="file" name="image1"></td>
</tr>
<tr>
<td><input type="submit" value="submit"></td>
</tr>
</table>
</form>
</head>
</title>