Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomvat 5.5.11 having trouble finding Servlets

 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. I'm having a little trouble with Tomcat 5.5.11 and Servlets...

Basically I have a web based system which allows users to login and browse/upload/download images at will

I have created the basic JSPs and file structure
C:\Java\Tomcat 5.5\webapps\web
Java classes are under - C:\Java\Tomcat 5.5\webapps\web\WEB-INF\classes\uk\co\domain\...

Servlets are under a folder in here called [servlets]
C:\Java\Tomcat 5.5\webapps\web\WEB-INF\classes\uk\co\domain\servlets

I have written the LoginServlet and it is under the following above address and it works fine. But
I have a Servlet called UploadServlet for uploading images i the same folder, mapped in the web.xml (see below) and
called in the following form:

<form name="frmUploader" action="UploadServlet" method="POST">

Page just redirects to a 404 [The requested resource (/web/secure/dam/uploader/UploadServlet) is not available]

<servlet id="Servlet_1136308272594">
<servlet-name>LoginServlet</servlet-name>
<servlet-class>uk.co.domain.servlets.LoginServlet</servlet-class>
</servlet>
<servlet id="Servlet_1136308272595">
<servlet-name>UploadServlet</servlet-name>
<servlet-class>uk.co.domain.servlets.UploadServlet</servlet-class>
</servlet>

<servlet-mapping id="ServletMapping_1136308273704">
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet-mapping id="ServletMapping_1136308273705">
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/UploadServlet</url-pattern>
</servlet-mapping>

As I say, the LoginServket works fine so why would the be a problem with the UploadServlet?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you look in your Tomcat logs for error messages?

What upload library are you using?
In order to upload files you need to set the enctype to multipart/form-data.


Is your upload library rejecting no-multipart requests?
 
Ben Weng
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think Secker had gone that for to the multi-part part. According to your description, Secker try giving the path as "/web", docBase as "web" in the Context.xml, something like this:
<Context path="/web" docBase="web" ...>
and calling the servlet this way:
<form name="yourformname" action="/web/UploadServlet" ...>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic