• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

HTTP Status 404

 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, If I place my html file under WebContent, I am able to load my servlet. If I move html file to some folder under WebContent directory, I am getting HTTP Status 404 error. Please let me know
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you file is under WebContent you can access by "/file.jsp"
If you move your file, you will have to put the path "folder/file.jsp" or "/folder/file.jsp" i can not tell you for sure now.

Could you post your code here? and your tree folders?
 
Greenhorn
Posts: 22
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


you change your web.xml?
 
Ranch Hand
Posts: 300
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

As suggested by Victor , issue could be with url pattern mapping , if you could post your web.xml , we can help probably help better.
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the completed code:

Web.xmlTestServlet.javaTestMe.htmlWhen I run, http://localhost:8080/ctWeb/html/TestMe.html

ctWeb is my project
html is a directory under Webcontent
When I click button on HTML page, Page is navigated to http://localhost:8080/ctWeb/html/TestServlet.do The following is the error in browser

HTTP Status 404 - /ctWeb/html/TestServlet.do

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

type Status report

message /ctWeb/html/TestServlet.do

description The requested resource (/ctWeb/html/TestServlet.do) is not available.
 
Victor Hugo M Machado
Greenhorn
Posts: 22
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you try this waht happen?

http://localhost:8080/ctWeb/TestServlet.do

 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This will work because we are calling Servlet directly. Requirement is, I have to call the Servlet from html file that is located in a directory.

Victor Hugo M Machado wrote:if you try this waht happen?

http://localhost:8080/ctWeb/TestServlet.do

 
Victor Hugo M Machado
Greenhorn
Posts: 22
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you change this..


and try this..
http://localhost:8080/ctWeb/html/TestMe.html

what happen?
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting same Exception,

HTTP Status 404 - /ctWeb/html/TestServlet.do

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

type Status report

message /ctWeb/html/TestServlet.do

description The requested resource (/ctWeb/html/TestServlet.do) is not available.


 
Sheriff
Posts: 67750
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
This is covered in the FAQs. You should be using a server-relative URL for the action that starts with the context path.

For example:

P.S. What's with the ".do"? Just because Struts uses that as a pattern to invoke its dispatcher doesn't mean it's necessary for all servlets.
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear, Please send me the FAQ URL. I couldn't find. BTW, Where should I change it
 
Bear Bibeault
Sheriff
Posts: 67750
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
I believe it's one of the JSP FAQs.

This is how to declare a form action to a Servlet. (The same applies to referencing images, scripts and stylesheets).
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I use this, I am getting following error

HTTP Status 404 - /ctWeb/html/$%7BpageContext.request.contextPath%7D/TestServlet

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

type Status report

message /ctWeb/html/$%7BpageContext.request.contextPath%7D/TestServlet

description The requested resource (/ctWeb/html/$%7BpageContext.request.contextPath%7D/TestServlet) is not available.


Bear Bibeault wrote:This is covered in the FAQs. You should be using a server-relative URL for the action that starts with the context path.

For example:

P.S. What's with the ".do"? Just because Struts uses that as a pattern to invoke its dispatcher doesn't mean it's necessary for all servlets.

 
Bear Bibeault
Sheriff
Posts: 67750
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
Looks like your web is is misconfigured such that the EL is not enabled.

Be sure that your web.xml is correctly declared as outlined in the JSP FAQ. (For example, if you are using the Servlets 2.3 DTD in your web.xml, it's wrong.)
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have DTD. I see xsd in my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
</web-app>
 
Bear Bibeault
Sheriff
Posts: 67750
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
Then the EL should be enabled in your JSPs.

What happens when you hit a JSP that contains just the following:?
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
7 is displayed in the browser.
 
Bear Bibeault
Sheriff
Posts: 67750
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
OK, the EL is correctly enabled. Be sure you are not disabling it on the page in question.

Then take a look at the HTML for the <form> element after is has been sent to the browser. Does it look correct?
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did not understand "Be sure you are not disabling it on the page in question. ". Also, I did not understand "Then take a look at the HTML for the <form> element after is has been sent to the browser". Please advice..
 
Bear Bibeault
Sheriff
Posts: 67750
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
1) There are directives that will disable the EL. Be sure you are not using them.

2) Look at the HTML in the browser. Usually something like "View source" on the menus.
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

I do not have any directives as given in the source code above. View source looks good to me.

Bear Bibeault wrote:1) There are directives that will disable the EL. Be sure you are not using them.

2) Look at the HTML in the browser. Usually something like "View source" on the menus.

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, rename your "TestMe.html" to "TestMe.jsp".
Then, modify your form declaration to: .
After that, test the JSP in the browser and verify that in the outputed HTML (view source), the action in the form is "/ctWeb/TestServlet.do".
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see the following, when I say, view--> source

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

</head>
<body>
<form action="/ctWeb/TestServlet.do">
<input type="submit" value="Send"></form>
</body>
</html>
 
Nick White Ro
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And does the servlet work?
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.

Nick White Ro wrote:And does the servlet work?

 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is working fine now..Thanks Nick and Bear. Renaming from "TestMe.html" to "TestMe.jsp" fixed the issue.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic