This is an HTML question rather than JSP or Tomcat but you just use <INPUT type="file" name="field_name">
-----Original Message----- From: Maruthi [mailto:[EMAIL PROTECTED] Sent: 10 August 2004 14:57 To: Tomcat Users List Subject: RE: How to Upload a File Using JSP?.(Snippest of code needed) Hello, Thanks for your reply.I could download the cos.jar from the given webiste.Then later onwards i am not able to proceed....i mean how to provide the functionality of uploading into my JSP.My JSP contains two textboxes and now i have to include the functionality of uploading.Please help me how to proceed. Thanks for your time and patience, Maruthi. =================================================== My JSP Code:: ===================================================== <%@ page language="java" contentType="text/html" %> <%@ page import = "java.io.*" %> <%@ page import = "java.lang.*" %> <%@ page import = "java.sql.*" %> <%@ page import = "org.apache.turbine.util.RunData" %> <%@ page import = "org.apache.turbine.util.Log" %> <%@ page import = "javax.servlet.http.*" %> <%@ taglib uri='/WEB-INF/templates/jsp/tld/template.tld' prefix='jetspeed' %> <%@ page import="org.apache.commons.fileupload.*" %> <% try { if(request.getMethod().equals("POST")) { RunData rundata=(RunData)request.getAttribute("rundata"); String jspeid = (String) request.getAttribute("js_peid"); String cpu1= request.getParameter("cpu"); String architecture1= request.getParameter("architecture"); Class.forName("org.gjt.mm.mysql.Driver"); Connection con=DriverManager.getConnection("Jdbc:mysql://localhost:3306/Thesiswork","root",""); Statement st=con.createStatement(); String str="INSERT into submitjobs VALUES('"+cpu1+"','"+architecture1+"','"+file1+"')"; int i=st.executeUpdate(str); System.out.println("Number of Rows inserted into AddGridNodes Table is: " +i+"<br>"); out.println( "<HTML><HEAD><TITLE>Confirmation-Added Grid Nodes</TITLE></HEAD>" ); out.println( "<BODY bgcolor=blue text=white><br>"); out.println( "<h2 align=center><FONT face=Verdana,Geneva,Arial color=white size=4><b>ADD JOBS</b></font></h2>"); out.println("<FONT face=Verdana,Geneva,Arial size=1>"); out.println( "<table align=center><br>"); out.println("<tr><td><b>The Details Belongs to Job: </td><td></td><td>"+cpu1+" is added to the Database..!.</b></td></tr><br>"); out.println("</table>"); out.println("</font>"); out.println("</BODY>"); out.println("</HTML>"); st.close(); con.close(); }else { %> <body bgcolor=blue text=white> <form action="SubmitJobs.jsp" enctype="multipart/form-data" method="POST"><br><br> <FONT face=Verdana,Geneva,Arial color=white size=1> <br> <h2 align="center"><FONT face=Verdana,Geneva,Arial color=white size=4><b>SUBMIT JOBS</b></font></h2> <br> <center> <table align="center" > <tr> <td><b><FONT face=Verdana,Geneva,Arial color=white size=2>CPU:<sup>*</sup></FONT></b></td> <td> </td><td> </td> <td><input type="text" name="cpu" value="" size="20"></td> </tr> <tr> <td><b><FONT face=Verdana,Geneva,Arial color=white size=2>Architecture:<sup>*</sup></FONT></b></td> <td> </td><td> </td> <td><input type="text" name="architecture" value="" size="20"></td> </tr> <tr> <td><b><FONT face=Verdana,Geneva,Arial color=white size=2>Execute PBS File:<sup>*</sup></FONT></b></td> <td> </td><td> </td> <td><INPUT TYPE="file" NAME="fileToUpload"></td</td> </tr> </table> <br><br> <input type="submit" value="Submit" /> </center> </font> </form> </body> <% } //else }catch (Exception e) { Log.error(e); return; } %> Rowland Watkins <[EMAIL PROTECTED]> wrote: Maruthi, I found the commons fileupload to be a bit heavy. You could try the O'Reilly Upload Servlet: http://www.servlets.com/resources/com.oreilly.servlet/ This has a simpler API. Just specify the directory for the file being uploaded and it does the rest. If you require multiple files to be uploaded it may be more suitable to use Struts. Cheers, Rowland --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Do you Yahoo!? Yahoo! Mail is new and improved - Check it out!
Any opinions expressed in this E-mail may be those of the individual and not necessarily the company. This E-mail and any files transmitted with it are confidential and solely for the use of the intended recipient. If you are not the intended recipient or the person responsible for delivering to the intended recipient, be advised that you have received this E-mail in error and that any use or copying is strictly prohibited. If you have received this E-mail in error please notify the beCogent postmaster at [EMAIL PROTECTED] Unless expressly stated, opinions in this email are those of the individual sender and not beCogent Ltd. You must take full responsibility for virus checking this email and any attachments. Please note that the content of this email or any of its attachments may contain data that falls within the scope of the Data Protection Acts and that you must ensure that any handling or processing of such data by you is fully compliant with the terms and provisions of the Data Protection Act 1984 and 1998.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
