File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having problem in running servlet

 
Prasenjit Singh
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a new to servlet. Here is the sample code :

Class signature is :
-----------------------------
public class UploadImage extends HttpServlet{

-----------------------------

Web.xml is :
-----------------------------

<servlet>
<servlet-name>uploadFile</servlet-name>
<servlet-class>upload.UploadImage</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>uploadFile</servlet-name>
<url-pattern>/upload</url-pattern>
</servlet-mapping>

--------------------------------------
I have placed the UploadImage class in Admin package.

Running using Netbeans Glassfish server.
Please let me know if there is any error as I am getting error:

===========================
HTTP Status 404 - Servlet uploadFile is not available

type Status report

messageServlet uploadFile is not available

descriptionThe requested resource (Servlet uploadFile is not available) is not available.

============================

HTML Page code is :

-------------------------------
<form action="upload" method="post" enctype="multipart/form-data" name="productForm" id="productForm"><br><br>
<table width="400px" align="center" border=0 style="background-color:ffeeff;">
<tr>
<td align="center" colspan=2 style="font-weight:bold;font-size:20pt;">Image Details</td>
</tr>

<tr>
<td align="center" colspan=2> </td>
</tr>

<tr>
<td>Image Link: </td>
<td>
<input type="file" name="file" id="file">
<td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>

</table>
</form>
----------------------------
 
Prasad Krishnegowda
Ranch Hand
Posts: 665
4
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your HTML action says "upload" but the error message says
"description The requested resource (Servlet uploadFile is not available) is not available. "

Are you sure you have pasted correct code and error message?

EDIT: Java coding standards, say, package names should be small characters, please also follow the standards/guidelines...
 
Prasenjit Singh
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please look at this post again. It was closed by mistake..
 
Rogerio Kioshi
Ranch Hand
Posts: 690
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try

 
Prasenjit Singh
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I have posted the correct error
 
Prasenjit Singh
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rogerio Kioshi wrote:try



Not working
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64181
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Form actions should be server-relative, starting with the context path of the web app. See the JspFaq for information on correctly formatting these URLs.
 
Prasenjit Singh
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well thanks for all answers. I found the answer myself. It was because I only added "commons-fileupload-1.2.1.jar". One more library was needed to be added. It was "commons-io-2.3.jar". After adding this library, it started working fine for me. I dont know but atleast it should throw some error regarding this..

Well problem is already solved.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic