File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Having problem in running servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Having problem in running servlet" Watch "Having problem in running servlet" New topic
Author

Having problem in running servlet

Prasenjit Singh
Greenhorn

Joined: Jan 24, 2013
Posts: 7
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

Joined: Apr 25, 2010
Posts: 589
    
    3

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

Joined: Jan 24, 2013
Posts: 7
Please look at this post again. It was closed by mistake..
Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
try



SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Prasenjit Singh
Greenhorn

Joined: Jan 24, 2013
Posts: 7
Yes I have posted the correct error
Prasenjit Singh
Greenhorn

Joined: Jan 24, 2013
Posts: 7
Rogerio Kioshi wrote:try



Not working
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Prasenjit Singh
Greenhorn

Joined: Jan 24, 2013
Posts: 7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Having problem in running servlet