• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Cannot find file..? Help

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

Im new to Servlets JSP's etc.., having some issues with the stuff below.

I have a servlet (just a test one for now) that in its post method just forwards the requester to google ,

response.sendRedirect("http://www.google.com");
return;

The JSP that calls this is has the following

<form method="POST" action="../servlet/servlets.UploadServlet"/>

The web.xml has the following code (I modified after reading some of the postings)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
- <web-app>
<display-name>mcaiyzm2 Web Application</display-name>
<description>mcaiyzm2 web application for JRun</description>
- <servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>UploadServlet</servlet-class>
</servlet>
- <servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/servlets</url-pattern>
</servlet-mapping>
</web-app>

The servlet is stored in the directory structure /web-inf/classes/servlets

When i click the button, in the url, it says "The file that you requested could not be found on this server. "

What have I done wrong?

All the help that u can give me will be appreciated.

Thanks in advance
Zein
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bug 1, servlet deployment setup, it should be

<servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>servlets.UploadServlet</servlet-class>
</servlet>

Bug 2, url mapping

<form method="POST" action="../servlet/servlets.UploadServlet"/>

does not match

<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/servlets</url-pattern>
</servlet-mapping>
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Danny,

Thanks for the above, still doesnt work. Says HTTP 404 - File not found.

<servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>servlets.UploadServlet</servlet-class>
</servlet>

Web.xml has been modified as above. Also post action has been modified to look like

<form method="POST" action="servlets.UploadServlet"/>

with the corresponding web.xml like below

<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/servlets</url-pattern>
</servlet-mapping>

Any ideas?

Regards
Zein
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mapped the servlet to the url, /servlets, and tried to invoke 'servlets.UploadServlet' by the form action. That's why you got the status code 404.

Try again with <form method="POST" action="/servlets"/>.

Regards,
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well guys,

This issue is still out standing, now the error is

HTTP 405 - Resource not allowed
Internet Information Services

The jsp post reads
<form method="POST" action="/servlets"/>

The web.xml is as follows

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
- <web-app>
<display-name>mcaiyzm2 Web Application</display-name>
<description>mcaiyzm2 web application for JRun</description>
- <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
- <servlet>
- <init-param>
<param-name>browseDirs</param-name>
<param-value>false</param-value>
</init-param>
<servlet-name>FileServlet</servlet-name>
<servlet-class>jrun.servlet.file.FileServlet</servlet-class>
<description>This servlet may override a corresponding FileServlet in SERVER-INF/default-web.xml.If removed, the servlet in default-web.xml will be used.</description>
</servlet>
<distributable>false</distributable>
- <servlet>
<!-- Above this is default -->
<servlet-name>UploadServlet</servlet-name>
<servlet-class>servlets.UploadServlet</servlet-class>
</servlet>
- <servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/servlets</url-pattern>
</servlet-mapping>
</web-app>

Directory structure is

WEB-INF\classes\servlets


And the post method is as follow

public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<HTML>");
out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>");
out.println("<BODY>");
out.println("<BIG>Hello World</BIG>");
out.println("</BODY></HTML>");

}
What have i dont wrong now? Its all correct as far as i can see?!!!
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the web.xwl in the servlet-mapping tag should be

<url-pattern>/servlet/servlets/UploadServlet</url-pattern>
 
Heonkoo Lee
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The url in <url-pattern>/servlets</url-pattern> seems like causing the problem. '/servlet' and '/servlets' might be used by the servlet container to dynamically invoke servlets with no mapping information when the user sends a request by calling /servlet/packagename.SomeServlet.

So, why don't you try with different url-pattern like

<url-pattern>/UploadFile/*</url-pattern>

and use <form method="POST" action="/UploadFile"> in the jsp.

This issue is still out standing, now the error is

HTTP 405 - Resource not allowed
Internet Information Services


Looks like it's from IIS web server. What servlet container are you using?
[ April 03, 2005: Message edited by: Heonkoo Lee ]
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers Guys , the problem has been kinda solved.

See im on a university network etc.., soo theres alot of thing we dont have control over, for starters installing the server etc.

It turns out some 'environmental' varible [quote from the technician] isnt right, the lab technician will fix it later.

Damn thing had me pulling my hair out..
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well ok the problem is completely solved now.

instead of using ../servlet, I had to use ./servlet [not one dot]. Reason is, my jsp's etc.. are not in a folder, they just lie in the root directory.

Thanks for the help guys, really appreciated
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic