0
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>MyController</servlet-name>
    <servlet-class>com.pk.MyController</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>MyController</servlet-name>
    <url-pattern>/MyController</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

I have this configuration, but unable to access hzhfyp.com/MyController (PAGE NOT FOUND)

The Path for MyController servelet is WEB-INF/classes/com/pk/MyController.class

Although index.jsp is loaded accuratelty. Demo here http://hzhfyp.com/ Clicking any button will generate js error visible in Firebug(firefox) as Page not Found.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Asad kamran
  • 440
  • 10
  • 21

1 Answers1

0

URLs are case sensitive. You've mapped it on /MyController with M, but your jQuery code is calling it by /myController with m. Fix it accordingly.

As to the servlet returing a 404 in spite of the correct URL, this can happen when the servlet failed to initialize or when you didn't deploy the correct web.xml at all. Read the server startup logs for any errors during servlet initialization and verify if you're deploying with the right web.xml.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Sorry i change it in last moment before copy paste, it was /myController earlier. I change it to /myController now, but still no findings, ANy further help. – Asad kamran May 09 '11 at 12:56
  • http://hzhfyp.com/myController 404 Not Found HeadersPostResponseHTML 404 Not Found

    Not Found

    The requested URL /myController was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    – Asad kamran May 09 '11 at 12:57
  • I am testing on web server. how to check ? from CPanel?? – Asad kamran May 09 '11 at 12:58
  • I have no idea what hosting you're using and I have no idea what you mean with "CPanel". Just contact your hosting support. Does it work when you run it locally? – BalusC May 09 '11 at 13:00
  • Cpanel control panel for webserver, here i checked the logs, which display page not found errors but i can not view tomcat server log. Yes, on local machine it works, but online it not mapped correctly. ANyway Thanks for your suggestion. – Asad kamran May 09 '11 at 13:37
  • Contact your hosting support and ask how to view tomcat logs. In future, consider dedicated, colocated or clustered hosting which is really designed for JSP/Servlet. Google Appengine maybe? After googling, the Cpanel thing seems to be specific to elcheapo PHP hostings. – BalusC May 09 '11 at 13:38