Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 6th, 2006, 05:15 AM
Registered User
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default attach a file and save it in the databas

Hello sir,
              I want to uplaod a file in jsp and want to store it the the data base (Ms SQL)....I need the code...Kindly please send me the code at

              [email protected]

Old December 11th, 2006, 04:10 AM
Registered User
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

hello friend...
i hv a code for storin data in the database...
u can try this...
this code is fr JDBC ....

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.net.*;

public class Test2db extends HttpServlet

           Connection theConnection;
                  private ServletConfig config;
               public void init(ServletConfig config)
                   throws ServletException

public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
                PrintWriter out = response.getWriter ();
                String first, email,site;
                first = (String)request.getParameter ("first");
                email = (String)request.getParameter ("email");
                site = (String)request.getParameter ("site");

                try {
            theConnection = DriverManager.getConnection("jdbc:odbc:SUSCET");
            Statement theStatement=theConnection.createStatement();

ResultSet theResult=theStatement.executeQuery("insert into emaillists values("+"'"+first +"'," +"'"+ email +"'," +"'" +site+"'" +")");

         out.println ("");

            theResult.close();//Close the result set
            theStatement.close();//Close statement
            theConnection.close(); //Close database Connection

         catch(Exception e)

out.println("<title>Input Servlet Test</title>");
out.println("<body bgColor=blanchedalmond text=#008000 topMargin=0>");
out.println("<form method='POST' action='../servlet/email1db'>");
out.println("<div align='Center'>");
out.println("Your Data has been stored in database successfully");

out.println("Click here to see the database");
out.println("<div align='Center'>");
out.println("<INPUT TYPE='submit' name='Submit' value='Click Here'>");



u can try this code ...

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I attach a file to an email in my .vbs file savoym VBScript 3 July 2nd, 2011 08:02 AM
Save PDF file as text file in VB.Net kvenkatu Classic ASP Basics 0 April 7th, 2006 01:09 PM
save a PDF file as text file through VB. NET kvenkatu VB.NET 0 April 6th, 2006 12:15 PM
upload, attach and send file naeemsyed Classic ASP Basics 4 March 7th, 2004 09:32 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.