tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sam Seaver" <samsea...@hotmail.com>
Subject RE: Error with multipartParser
Date Tue, 15 Oct 2002 14:26:06 GMT
Jon,

Thank you, that solved my problem, I was sure it was a class thing but just 
didn't realise that TomCat would never look at the normal classpath!! So it 
works now :-)

One more thing though, if I don't give the file a filepath, it automatically 
puts it in this one folder where I do not expect it to be, is there a 
default somewhere that I'm missing?

cheers
S


>From: "jon wingfield" <jon.wingfield@mkodo.com>
>Reply-To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>Subject: RE: Error with multipartParser
>Date: Fri, 11 Oct 2002 11:11:38 +0100
>
>tomcat doesn't use the classpath. It derives where tools.jar is from the
>JAVA_HOME environment variables. Your application classes should be placed
>under CATALINE_HOME/webapps/YOUR_WEBAPP_NAME/WEB-INF/classes and your
>application jar files (ie cos.jar) under
>CATALINE_HOME/webapps/YOUR_WEBAPP_NAME/WEB-INF/lib (where YOUR_WEBAPP_NAME
>is sam, i think)
>
>Take a look at this doc
>http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/deployment.html
>
>-----Original Message-----
>From: Sam Seaver [mailto:samseaver@hotmail.com]
>Sent: 10 October 2002 21:32
>To: tomcat-user@jakarta.apache.org
>Subject: RE: Error with multipartParser
>
>
>i'm using TomCat 4.1.12, and I still get the same error, whether I use the
>extra code or not.  the point is that it works fine if I don't try to
>instantiate MultipartParser, and the same happens with MultipartRequest, as
>soon as I add the line:
>
>'MultipartWhatever whatever = new multipartWhatever(requirements 
>fulfilled)'
>
>then i just get the same error.  my classpath is:
>
>/usr/local/j2sdk1.4.1/lib:/usr/local/j2sdkee1.3.1/lib:/usr/local/jakarta-tom
>cat-4.1.12/common/lib/servlet.jar:/usr/local/cos/lib/cos.jar:/usr/local/j2sd
>k1.4.1/lib/tools.jar:/home/seaver/web:.
>
>including the cos.jar and the tools.jar, but it just seems to have a 
>problem
>with cos...anyone?
>
>S
>
>
> >From: "Rajiv Ramanasankaran" <rajiv@altec.org>
> >Reply-To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
> >To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
> >Subject: RE: Error with multipartParser
> >Date: Thu, 10 Oct 2002 15:19:12 -0500
> >
> >I forgot to mention that I added this code to your bean :)
> >try{
> >             setOutput("Demo Parser Upload Bean");
> >             MultipartParser mp = new MultipartParser(req, 10*1024*1024);
> >             Part part;
> >             while ((part = mp.readNextPart()) != null) {
> >                 String name = part.getName();
> >                 if (part.isParam()) {
> >                     // it's a parameter part so do nothing
> >                 }
> >                 else if (part.isFile()) {
> >                     // it's a file part
> >                     FilePart filePart = (FilePart) part;
> >
> >                     if (getFileName()!= null) {
> >                         // the part actually contained a file
> >                         File filepath=new File("c:/Temp/rajiv.xml");
> >                         long size = filePart.writeTo(filepath);
> >                         setFileName(filePart.getFileName());
> >                     }
> >                     else {
> >                         //file was empty add error code here
> >                     }
> >                 }
> >             }
> >         }catch(Exception e){
> >             e.printStackTrace();
> >         }
> >you have to specify the directory or file to which you want to upload.
> >
> >-----Original Message-----
> >From: Rajiv Ramanasankaran [mailto:rajiv@altec.org]
> >Sent: Thursday, October 10, 2002 2:50 PM
> >To: Tomcat Users List
> >Subject: RE: Error with multipartParser
> >
> >
> >Its is working fine for me!! The file is getting uploaded and I don't get
> >an
> >error at all..What version of Tomcat are you using??? I am using Tomcat 
>3.2
> >. There might be an incompatibility problem.
> >Rajiv
> >
> >-----Original Message-----
> >From: Sam Seaver [mailto:samseaver@hotmail.com]
> >Sent: Thursday, October 10, 2002 2:11 PM
> >To: tomcat-user@jakarta.apache.org
> >Subject: RE: Error with multipartParser
> >
> >
> >OK, here's the JSP page I'm using, note it reloads itself once POST is
> >pressed, and then activates the bean:
> >
> ><html>
> ><head>
> ><title>file upload</title>
> ></head>
> ><body bgcolor="#c8d8f8">
> ><form action="jguru.jsp" enctype="multipart/form-data" method=post>
> ><center>
> ><table cellpadding=4 cellspacing=2 border=0>
> >
> ><th bgcolor="#CCCCFF" colspan=2>
> ><font size=5>User Registration</font>
> ></th>
> >
> ><tr>
> ><td valign=top colspan=2>
> ><b>Which XML file would you like to upload?</b>
> ><br />
> ><input type="file" name="fileName"  />
> ><br></td>
> ></tr>
> >
> ><tr>
> ><td  align=center colspan=2>
> ><input type="submit" value="Submit"> <input type="reset"  value="Reset">
> ></td>
> ></tr>
> >
> ></table>
> ></center>
> ></form>
> >
> ><%-- Create the bean only when the form is posted --%>
> ><%
> >if (request.getMethod().equals("POST")) {
> >%>
> ><jsp:useBean id="xmlHandler" class="com.jguru.SimpleBean">
> ><jsp:setProperty name="xmlHandler" property="fileName" />
> ></jsp:useBean>
> ><p>
> ><hr>
> ><font color=red>
> ><br><b>File to upload:</b><br>
> ><jsp:getProperty name="xmlHandler" property="fileName" />
> ><br>
> ><%
> >xmlHandler.doPost(request, response);
> >%>
> ><br/><b>Bean Output:</b><br/>
> ><jsp:getProperty name="xmlHandler" property="output" />
> ><%
> >}
> >%>
> ></font>
> ></body>
> ></html>
> >
> >then there's the bean itself:
> >
> >package com.jguru;
> >
> >import java.io.*;
> >import java.util.*;
> >import javax.servlet.http.*;
> >import javax.servlet.*;
> >
> >import com.oreilly.servlet.*;
> >import com.oreilly.servlet.multipart.*;
> >
> >public class SimpleBean extends HttpServlet {
> >
> >     private String fileName;
> >     private String name;
> >     private String type;
> >     private String output;
> >
> >     public SimpleBean(){
> >	fileName="";
> >	name="";
> >	type="";
> >	output="";
> >     }
> >
> >     public void setFileName(String x){
> >	fileName=x;
> >     }
> >
> >     public void setName(String x){
> >	name=x;
> >     }
> >
> >     public void setType(String x){
> >	type=x;
> >     }
> >
> >     public void setOutput(String x){
> >	output=x;
> >     }
> >
> >     public void appendOutput(String x){
> >	output=output+x;
> >     }
> >
> >     public String getFileName(){
> >	return fileName;
> >     }
> >
> >     public String getName(){
> >	return name;
> >     }
> >
> >     public String getType(){
> >	return type;
> >     }
> >
> >     public String getOutput(){
> >	return output;
> >     }
> >
> >     public void doPost(HttpServletRequest req, HttpServletResponse res)
> >	throws ServletException, IOException{
> >	try{
> >	    setOutput("Demo Parser Upload Bean");
> >	    MultipartParser mp = new MultipartParser(req, 10*1024*1024);
> >	}catch(Exception e){
> >	    e.printStackTrace():
> >	}
> >     }
> >}
> >
> >the log gave very little, what i cut and pasted was from the log, but 
>with
> >the stacktrace this is what it did:
> >
> >2002-10-10 14:09:29 StandardContext[/sam]: Mapping contextPath='/sam' 
>with
> >requestURI='/sam/jguru.jsp' and relativeURI='/jguru.jsp'
> >2002-10-10 14:09:29 StandardContext[/sam]:   Trying exact match
> >2002-10-10 14:09:29 StandardContext[/sam]:   Trying prefix match
> >2002-10-10 14:09:29 StandardContext[/sam]:   Trying extension match
> >2002-10-10 14:09:29 StandardContext[/sam]:  Mapped to servlet 'jsp' with
> >servlet path '/jguru.jsp' and path info 'null' and update=true
> >2002-10-10 14:09:33 StandardContext[/sam]: Mapping contextPath='/sam' 
>with
> >requestURI='/sam/jguru.jsp' and relativeURI='/jguru.jsp'
> >2002-10-10 14:09:33 StandardContext[/sam]:   Trying exact match
> >2002-10-10 14:09:33 StandardContext[/sam]:   Trying prefix match
> >2002-10-10 14:09:33 StandardContext[/sam]:   Trying extension match
> >2002-10-10 14:09:33 StandardContext[/sam]:  Mapped to servlet 'jsp' with
> >servlet path '/jguru.jsp' and path info 'null' and update=true
> >2002-10-10 14:09:33 StandardWrapperValve[jsp]: Servlet.service() for
> >servlet
> >jsp threw exception
> >org.apache.jasper.JasperException:
> >com/oreilly/servlet/multipart/MultipartParser
> >         at
> >org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
>2
> >48)
> >         at
> >org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
> >         at
> >org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >         at
> >org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>n
> >FilterChain.java:247)
> >         at
> >org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>h
> >ain.java:193)
> >         at
> >org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j
>a
> >va:260)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:643)
> >         at
> >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> >         at
> >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >         at
> >org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j
>a
> >va:191)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:643)
> >         at
> >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> >         at
> >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >         at
> >org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
> >         at
> >org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:18
>0
> >)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:643)
> >         at
> >org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve
>.
> >java:170)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:641)
> >         at
> >org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:17
>2
> >)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:641)
> >         at
> >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> >         at
> >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >         at
> >org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav
>a
> >:174)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:643)
> >         at
> >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> >         at
> >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >         at
> >org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> >         at
> >org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
> >         at
> >org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConn
>e
> >ction(Http11Protocol.java:380)
> >         at
> >org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
> >         at
> >org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
>v
> >a:533)
> >         at java.lang.Thread.run(Thread.java:536)
> >----- Root Cause -----
> >javax.servlet.ServletException:
> >com/oreilly/servlet/multipart/MultipartParser
> >         at
> >org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextIm
>p
> >l.java:497)
> >         at org.apache.jsp.jguru_jsp._jspService(jguru_jsp.java:128)
> >         at
> >org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >         at
> >org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
>2
> >04)
> >         at
> >org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
> >         at
> >org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >         at
> >org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>n
> >FilterChain.java:247)
> >         at
> >org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>h
> >ain.java:193)
> >         at
> >org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j
>a
> >va:260)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:643)
> >         at
> >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> >         at
> >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >         at
> >org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j
>a
> >va:191)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:643)
> >         at
> >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> >         at
> >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >         at
> >org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
> >         at
> >org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:18
>0
> >)
> >:
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:643)
> >         at
> >org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve
>.
> >java:170)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:641)
> >         at
> >org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:17
>2
> >)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:641)
> >         at
> >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> >         at
> >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >         at
> >org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav
>a
> >:174)
> >         at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invo
>k
> >eNext(StandardPipeline.java:643)
> >         at
> >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> >         at
> >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >         at
> >org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> >         at
> >org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
> >         at
> >org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConn
>e
> >ction(Http11Protocol.java:380)
> >         at
> >org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
> >         at
> >org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
>v
> >a:533)
> >         at java.lang.Thread.run(Thread.java:536)
> >
> >
> > >From: "Rajiv Ramanasankaran" <rajiv@altec.org>
> > >Reply-To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
> > >To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
> > >Subject: RE: Error with multipartParser
> > >Date: Wed, 9 Oct 2002 23:03:24 -0500
> > >
> > >Can you give the full exception stacktrace?? That might help us figure 
>it
> > >out. try e.printStackTrace() instead of creating the printwrite and
> > >printing
> > >to standard error. Send the tomcat log files too.
> > >Rajiv
> > >
> > > > -----Original Message-----
> > > > From: Sam Seaver [mailto:samseaver@hotmail.com]
> > > > Sent: Wednesday, October 09, 2002 2:09 PM
> > > > To: tomcat-user@jakarta.apache.org
> > > > Subject: Error with multipartParser
> > > >
> > > >
> > > > I cannot work this out as I get no more in my error messages
> > > > despite trying
> > > > to use the usual ways of debugging the bean.  Basically I'm using a
> >bean
> > > > that extends HttpServlet and uses Hunter's MultipartParser, and the
> > >error
> > > > ALWAYS occurs when I try to create an instance of the parser...
> > > >
> > > > Error:
> > > >
> > > > root cause
> > > >
> > > > javax.servlet.ServletException:
> > > > com/oreilly/servlet/multipart/MultipartParser
> > > > 	at
> > > > org.apache.jasper.runtime.PageContextImpl.handlePageException(Page
> > > > ContextImpl.java:497)
> > > >
> > > > Code:
> > > >
> > > > import java.io.*;
> > > > import java.util.*;
> > > > import javax.servlet.http.*;
> > > > import javax.servlet.*;
> > > >
> > > > import com.oreilly.servlet.*;
> > > > import com.oreilly.servlet.multipart.*;
> > > >
> > > > public class SimpleBean extends HttpServlet {
> > > >
> > > >     private String fileName;
> > > >     private String name;
> > > >     private String type;
> > > >     private String output;
> > > >
> > > >     public SimpleBean(){
> > > > 	fileName="";
> > > > 	name="";
> > > > 	type="";
> > > > 	output="";
> > > >     }
> > > >
> > > >     public void setFileName(String x){
> > > > 	fileName=x;
> > > >     }
> > > >
> > > >     public void setName(String x){
> > > > 	name=x;
> > > >     }
> > > >
> > > >     public void setType(String x){
> > > > 	type=x;
> > > >     }
> > > >
> > > >     public void setOutput(String x){
> > > > 	output=x;
> > > >     }
> > > >
> > > >     public void appendOutput(String x){
> > > > 	output=output+x;
> > > >     }
> > > >
> > > >     public String getFileName(){
> > > > 	return fileName;
> > > >     }
> > > >
> > > >     public String getName(){
> > > > 	return name;
> > > >     }
> > > >
> > > >     public String getType(){
> > > > 	return type;
> > > >     }
> > > >
> > > >     public String getOutput(){
> > > > 	return output;
> > > >     }
> > > >
> > > >     public void doPost(HttpServletRequest req, HttpServletResponse
> >res)
> > > > 	throws ServletException, IOException{
> > > > 	setOutput("Demo Parser Upload Bean");
> > > > 	res.setContentType("text/html");
> > > > 	ServletOutputStream out = res.getOutputStream();
> > > >
> > > > 	try{
> > > > 	    MultipartParser mpParser = new MultipartParser(req,
> > > > 10*1024*1024);
> > > > 	}catch (Exception e){
> > > > 	    StringWriter sw = new StringWriter();
> > > > 	    PrintWriter pw = new PrintWriter(sw);
> > > > 	    e.printStackTrace(pw);
> > > >
> > > > 	}
> > > >
> > > >
> > > >
> > > >     }
> > > > }
> > > >
> > > >
> > > >
> > > > "JC Rules"
> > > >
> > > > _________________________________________________________________
> > > > Chat with friends online, try MSN Messenger: 
>http://messenger.msn.com
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > ><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> > >For additional commands, e-mail:
> > ><mailto:tomcat-user-help@jakarta.apache.org>
> > >
> > >
> > >
> > >--
> > >To unsubscribe, e-mail:
> > ><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> > >For additional commands, e-mail:
> > ><mailto:tomcat-user-help@jakarta.apache.org>
> > >
> > >
> > >
> > >
> > >--
> > >To unsubscribe, e-mail:
> > ><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> > >For additional commands, e-mail:
> > ><mailto:tomcat-user-help@jakarta.apache.org>
> >
> >
> >"JC Rules"
> >
> >_________________________________________________________________
> >MSN Photos is the easiest way to share and print your photos:
> >http://photos.msn.com/support/worldwide.aspx
> >
> >
> >--
> >To unsubscribe, e-mail:
> ><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail:
> ><mailto:tomcat-user-help@jakarta.apache.org>
> >
> >
> >
> >
> >--
> >To unsubscribe, e-mail:
> ><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail:
> ><mailto:tomcat-user-help@jakarta.apache.org>
> >
> >
> >
> >
> >--
> >To unsubscribe, e-mail:
> ><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail:
> ><mailto:tomcat-user-help@jakarta.apache.org>
>
>
>"JC Rules"
>
>_________________________________________________________________
>Join the world’s largest e-mail service with MSN Hotmail.
>http://www.hotmail.com
>
>
>--
>To unsubscribe, e-mail:
><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
><mailto:tomcat-user-help@jakarta.apache.org>
>
>
>
>--
>To unsubscribe, e-mail:   
><mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: 
><mailto:tomcat-user-help@jakarta.apache.org>


"JC Rules"

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message