neuralcomplex 0 Newbie Poster

the simple thing i want to achieve is to be able to browse a file on my system an then use a servlet to finally store the file as a byte stream to my DB2 database. Initially i started by using coding the servlet part as a java application by explicitly mention the path of the file to be uploaded as the value of a String object. that worked fine. trouble started when i used an html form (which eventually has to be a jsp page) to search the file in the sysytem and then upload it.
here's my servlet "" code (this works fine standalone)

   //all the required imports go here

public class Up1 extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public Up1() {
        // TODO Auto-generated constructor stub

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        String filename=request.getParameter("filename");
        PrintWriter pw=response.getWriter();
            //InputStream sImage;
        Connection con= DriverManager.getConnection("jdbc:db2://localhost:50000/PHOTOTRY","db2admin","db2admin");
        File imgfile = new File(filename);  
        String id="1111";
        String name="myphoto";
        FileInputStream fin = new FileInputStream(imgfile);     
        PreparedStatement pre = con.prepareStatement("INSERT INTO EMP VALUES(?,?,?)");


        int success=pre.executeUpdate(); 
            pw.println("New Employee detail added");     

catch(Exception e)


     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub


and the supportin html file "page1.html"-


<form action="Up1" name="upform" enctype="multipart/form-data">
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
<td align="left"><b>Select a file to upload :</b></td>
<td align="left">
<input type="file" name="filename" size="50">
<td align="left">
<input type="hidden" name="todo" value="upload">
<input type="submit" name="Submit" value="Upload">
<input type="reset" name="Reset" value="Cancel">

the problem faced is that it throws a Exception as it couldn't find the file specified. and i jsut can't figure out WHY?
IDE- Eclipse Indigo
Backend- DB2
OS- Windows 7