Got it, thanks.  It was a library I wanted access to from a Web app.  Now I
have a new problem...

I'm trying to set up file upload.  My form and servlet are essentially
copies of the O'Reilly example. on submit I'm getting:

Error: 405
Location: /evoucher/FileUpload
HTTP method GET is not supported by this URL

which confuses me because there is no GET method, only POST.

----- form -----

<form action="/evoucher/FileUpload" enctype="multipart/form-data"
    method="POST" name="form1">
What is your name? <input type="text" name="submitter"><BR>
Which file do you want to upload? <input type="file" name="file"><BR>
<input type="submit"></form>

---- servlet ----

package cc.nisc.servlet;

import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

import com.oreilly.servlet.MultipartRequest;

public class FileUpload extends HttpServlet {

    public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();

        try {

            MultipartRequest multi = new MultipartRequest(req,
"/resources/uploads", 1024 * 1024);
            out.println("<HTML>");
            out.println("<HEAD><TITLE>Employee Self Serve File
Upload</TITLE>/HEAD>");
            out.println("<BODY>");
            out.println("<H1>File Upload</H1>");

            out.println("<H3>File Information:</H3>");
            out.println("<PRE>");
            Enumeration params = multi.getParameterNames();

            while (params.hasMoreElements()) {
                String name = (String)params.nextElement();
                String value = multi.getParameter(name);
                out.println(name + " = " + value);
            }

            out.println("</PRE>");

            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();
            }
            out.println("</PRE>");
        }
        catch (Exception e) {
            out.println("<PRE>");
            e.printStackTrace(out);
            out.println("</PRE>");
        }
        out.println("</BODY></HTML>");
    }
}


-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Sachin Pandey
Sent: Monday, May 20, 2002 6:34 PM
To: [EMAIL PROTECTED]
Subject: Re: JAR files in JBoss (off-topic)


If its an ejb jar or a war archive then put it in the jboss/deploy
directory.
If its just an library that u want access to then put it in the lib/ext
directory.

Hope that helps
Sachin

On Tuesday 21 May 2002 07:55, Greg Dunn wrote:
> Can anyone tell me where and how to deploy .jar files in
> JBoss-2.4.4_Tomcat-3.2.3?  There is no lib/common dir under Tomcat, I
tried
> a lib directory in my Ant built .war (<lib dir="lib"/>) and the lib/ext
dir
> under JBoss didn't work.
>
> Greg
>
>
>
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
> Galbreath, Mark
> Sent: Monday, May 20, 2002 4:03 PM
> To: [EMAIL PROTECTED]
> Subject: Re: how do i use session.setAttribute for arrays?
>
>
> Well, I notice a few things here.
>
> 1.  Java constants should be all upper-case, so "iMaxBookmarks" should be
> "IMAXBOOKMARKS," and Java variables and methods should begin lower-case
> chars, so "MyBookmarkArray" should be myBookmarkArray.
>
> 2. I can't see how in the world you are setting a session attribute called
> "MyBookmarkArray" with a ResultSet rs and undefined variable i.  I think
> what you want to do is something like
>
> int i = 0;
>
> while( rs.next) {
>   myBookmarkArray[i] = rs.getString( "bookmark");
>   i++;
> }
>
> rs.close();
> conn.close();
> session.setAttribute("myBookmarkArray", myBookmarkArray);
>
> 3.  In your JSP, iterate through the array to get the values:
>
> <%
>   Bookmark myBookmarkArray[] =
>   ( Bookmark) session.getAttribute( "myBookmarkArray");
>
>   for( int i = 0; i < myBookmarkArray.length(); i++) {
>     out.println( myBookmarkArray[i];
>   }
> %>
>
> 4.  You will find more help for this kind of stuff on the struts-user mail
> list at jakarta.apache.org/struts.
>
> Mark
>
> -----Original Message-----
> From: Richard Diaz [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 20, 2002 4:30 PM
>
> Here's what I'm doing:
>
> int iMaxBookmarks = 25;
> Bookmark[] MyBookmarkArray = new
> Bookmark[iMaxBookmarks];
>
> while (rs.next())
>   {
>   MyBookmarkArray[i] = new Bookmark();
>   session.setAttribute("MyBookmarkArray[" + i + "]",
> MyBookmarkArray);
> // set all data for MyBookmarkArray[i] (this works
> fine)...
>
> }
>
> // Close the ResultSet
> System.out.println("bookmarks done");
> rs.close();
>
> in my JSP page I get a NULL POINTER EXCEPTION...
>
> <%=MyBookmarkArray[1].getpk() %> </br>
>
> I have verified there are 3 bookmarks created.
>
> also I can see all my non array session variables just
> not this array one... a scope problem?
>
> Also, anyone know of a good JSP Forum? I need to also
> figure out how to loop output of the above array
> inside the JSP.
>
> thanks in advance.
> Rich
>
>
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

--
Sachin Pandey
Nuix Pty Ltd
(61)(02) 92839010

U can't erase my dreams, u can only wake me up.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to