Thanks alot.
The code really worked for me.
From:
Shuwaz.
----- Original Message -----
From: "Tripat Singh" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 06, 2000 5:21 PM
Subject: Re: Using Orielly Upload Package.
> Enclosed the code i used to implement file uploading using
> different filename. Feel free to ask any queries about it
>
> <code starts here>
>
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException {
> res.setContentType("text/html");
> PrintWriter out = res.getWriter();
>
> try {
>
> // Construct a MultipartRequest to help read the information.
> // Pass in the request, a directory to saves files to, and the
> // maximum POST size we should attempt to handle.
> // Here we (rudely) write to the server root and impose 5 Meg limit.
> MultipartRequest multi =
> new MultipartRequest(req, ".", 5 * 1024 * 1024);
>
> out.println("<HTML>");
> out.println("<HEAD><TITLE>Image Upload</TITLE>");
> out.println("</HEAD>");
> out.println("<body bgcolor=\"#CECE9C\"
> background=\"http://localhost:8082/map/jsp/images/bk_upload.gif\"
> onLoad=\"setTimeout(window.close, 5000)\" >");
> out.println("<H1>Image Upload</H1>");
>
> out.println("<form name=\"fr\" enctype=\"multipart/form-data\">");
> file://Print the parameters we received
> file://out.println("<H3>Params:</H3>");
> file://out.println("<PRE>");
> file://Enumeration params = multi.getParameterNames();
> file://while (params.hasMoreElements()) {
> // String name = (String)params.nextElement();
> // String value = multi.getParameter(name);
> // out.println(name + " = " + value);
> // System.out.println(name + " = " + value);
> file://}
> file://out.println("</PRE>");
>
> // Show which files we received
> out.println("<H3>Files:</H3>");
> out.println("<PRE>");
> Enumeration files = multi.getFileNames();
> while (files.hasMoreElements()) {
> String name = (String)files.nextElement();
> String filename = multi.getFilesystemName(name);
> String type = multi.getContentType(name);
> File f = multi.getFile(name);
> out.println("name: " + name);
> out.println("filename: " + filename);
> out.println("type: " + type);
> if (f != null) {
> out.println("length: " + f.length());
> out.println();
> file://create a new file name preserving the original file
extension.
> String newFileName = multi.getParameter("newFileName") +
> filename.substring(filename.length()-4,filename.length());
> File tempFile = new
File("d:\\jswdk\\jswdk-1.0.1\\map\\images\\"+
> newFileName);
> System.out.println(newFileName);
> f.renameTo(tempFile);
> }
> out.println("</PRE>");
> out.println("<p>");
> out.println("<H3>Your Image has been successfully uploaded.</H3>
<BR>
> This window will automatically close in 5 seconds.");
> }
> }
> catch (Exception e) {
> out.println("<PRE>");
> e.printStackTrace(out);
> out.println("</PRE>");
> }
> out.println("</BODY></HTML>");
> }
>
> <code ends here>
>
> Njoy!!!!!!!!!!
>
> Tripat.
>
> ----- Original Message -----
> From: "Shuja Nawaz" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, August 05, 2000 3:45 PM
> Subject: Using Orielly Upload Package.
>
>
> > Hi
> > Can you plz tell me how to customize Orielly package to customize it
so
> > that
> > I can use it on my JSP page by using the package classes as a bean.
> > a.. Upload the file with a new name.
> > b.. Can access all the parameters on the next page
> >
> > Hope to get quick response from you.
> >
> > Thanks.
> > From: Shuwaz.
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets