Home  
 
  Ask Questions  
 
  Feed Back  
 
  My Questions  
 
  Contact Us  
 
  About Us  
 
 Interview Questions  
 Our Services  

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies

  • NEW INTERVIEW QUESTIONS.COM J2EE INTERVIEW QUESTIONS JSP INTERVIEW QUESTIONS DETAILS


    NewInterviewQuestions.com - Home for World's Largest Interview Questions Website.

    A D V E R T I S E M E N T




    Add to My Questions Add to My Questions | Forward Forward | Print Print


    Question Question I want to accomplish the following scenario:
    1) user submits a jpg/gif file from an html form (using <input type="file"> in the form, the user can browse to a file of their choice)
    2) upload the jpg/gif file through a combination of Java and JSP's
    3) put the jpg/gif into a database on a server and/or into a folder on my local system.


    Answer Answer <%@ page import="java.sql.*,java.io.*,java.util.*,com.oreilly.servlet.MultipartRequest,com.microsoft.jdbc.sqlserver.SQLServerDriver;"%>
    <%

    /* The Following Code is Used To Insert An Image Into Database

    String filename="";
    try
    {
    MultipartRequest multi= new MultipartRequest(request,"d:/phani",5*1024*1024);
    Enumeration files=multi.getFileNames();
    File f=null;
    while(files.hasMoreElements())
    {
    String name=(String)files.nextElement();
    filename=multi.getFilesystemName(name);
    String type=multi.getContentType(name);
    f=multi.getFile(name);
    System.out.println("The File is "+f);
    }
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://172.21.1.11:1740;databasename=pubs","sa","satest");
    Statement stmt = con.createStatement();
    System.out.println("2 "+f);
    InputStream is = new FileInputStream(f);
    System.out.println("4 "+is);
    byte b[]=new byte[is.available()];
    is.read(b);
    String sql = "INSERT into photo_test (\"Photo\") values('" + b + "')";
    System.out.println("sql is " +sql);
    stmt.execute(sql);
    stmt.close();

    }catch(Exception e)
    {
    System.out.println(e);
    }
    out.println("The Image is Added into Database");


    interesting [URL=http://www.lcsc.edu/NS350/_discNS350/000003d7.htm?retin#] retin [/URL] retin http://www.lcsc.edu/NS350/_discNS350/000003d7.htm?retin retin

    Answered By: Michail    Date: 5/17/2007

    © NewInterviewQuestions.com


    If you have the better answer, than send it to us. We will display your answer after the approval.
    Answer Answer:*
    Name Name:*
    Email Address Email Address:*
         Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
     


    Rate the above answer. Help us to know about the answer.
    Category Category JSP Interview Questions
    Rating Rating (1.0) By 2 users
    Added Added 7/17/2006
    Views Views 154178
    Rate it Rate it!
    Free Offers Free Offers: 300 Free Magazines for you. No credit card required. No Shipping Charges. Absolutely Free for 1 Year.

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:


    A D V E R T I S E M E N T





     Sponsors  
    Latest 10 Answers
    ABAP is basic (technical) side of SAP. which helps other function of business sibe ex.financial,sales,inventory& human resource.
    Cluster index work as a primary key and as we know in a single table only one primary key should be there....Hence only one records can take cluster index.
    Select Employee.*, Department.* from Employee LEFT OUTER JOIN Department ON Employee.EmpId=Department.DeptId
    Both are the connection object but SQLCLIENT using while connect with Sqlserver database and OLEDB using while connect with MS-access database and Oracle database.
    Only 1 cluster index and 255 non cluster index.
    Because it's used to read the data from the DB as Read-only manner, only forward direction not backward..hence its not supporting edit operation.
    I will throw my wife because if my wife dies ican get another but mother is only one I cannot get another
    When mistake is found by compiler is known as ERROR , when a mistake is found by tester while testing is a BUG and when mistake is found by the end user it is known as DEFECT.
    Create customer code & transporter code, create sales order, checke the payment received then released order from Finance, delivery, billing, invoice.
    Invoice is a request sent by vendor for the payment against services/goods with all the necessary details like - Price, Rate, Quantity, Vendor Name, Vendor Address, Unique Invoice Number (From Vendor), Terms & Conditions.

    G o o g l e Search

    Google

    Newinterviewquestions.com is a part of Vyom Network. Top



    Copyright ? 2008, newinterviewquestions.com. All rights reserved Privacy Policy

    Page URL: http://www.newinterviewquestions.com/interview/5931/Default.asp?cachecommand=bypass


    Download Yahoo Messenger