• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Having problem in running servlet

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
----------------------------
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please look at this post again. It was closed by mistake..
 
Ranch Hand
Posts: 701
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try

 
Prasenjit Singh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I have posted the correct error
 
Prasenjit Singh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rogerio Kioshi wrote:try



Not working
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I'm so happy! And I wish to make this tiny ad happy too:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic