Results 1 to 4 of 4
  1. #1
    bakshadow is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default The requested resource (/servlet/org.Test.WebForm.Form) is not available

    Hello, before I ask for help I thought I should state that I am just starting to teach myself java servlets. Im not new to java, just servlets.
    Im trying to create a basic "Please enter your name here" hit submit and be have a new page thats says "Hello name." Im using O'reilly's java servlet programming book and I just can't seem to find what Im doing wrong.
    the code for my html page is:
    Java Code:
    <html>
    	<head>
    		<title>Introductions</title>
    	</head>
    	<body> 
    		<FORM ACTION="/servlet/org.Test.WebForm.Form" METHOD="get">
    		Name: <input type="text" name="name"><br>
    		<input type="submit" value="submit!">
    		</FORM>
    	</body>
    </html>
    My java code is:
    Java Code:
    package org.Test.WebForm;
    
    import java.io.*;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.*;
    
    public class Form extends HttpServlet 
    {
    	@Override 
    	public void doGet(HttpServletRequest req, HttpServletResponse res)
    								throws ServletException, IOException {
    		res.setContentType("text/html");
    		PrintWriter out = res.getWriter();
    		
    		String name = req.getParameter("name");
    		out.println("<HTML>");
    		out.println("<HEAD><TITLE>Hello</TITLE></HEAD>");
    		out.println("<BODY>");
    		out.println("hello, " + name);
    		out.println("</BODY></HTML>");
    	}
    	
    	public String getServletInfo()
    	{
    		return "A servlet that knows the name of the person to whom it's " +
    				"saying Hello";
    	}
    }
    I can get the html page to show but when I hit submit I get an error status saying " The requested resource (/servlet/org.Test.WebForm.Form) is not available" Thanks for the help

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    Have you mapped your servlet to that name in the web.xml?

  3. #3
    britto_bics is offline Member
    Join Date
    Nov 2008
    Posts
    3
    Rep Power
    0

    Default

    look at the web.xml
    there should be url-pattren and mapping tag .
    check wheter it is corret.

  4. #4
    bakshadow is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default

    Sorry, I forgot to show the xml code as well. the xml code is
    Java Code:
    <?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">
    <servlet>
    		<servlet-name>Test2</servlet-name>
    		<servlet-class>org.Test.WebForm.Form</servlet-class>
    	</servlet>
    	
    	<servlet-mapping>
    		<servlet-name>Test2</servlet-name>
    		<url-pattern>/servlet/org.Test.WebForm.Form</url-pattern>
    	</servlet-mapping>
    
      <display-name>TestForm</display-name>
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
    I thought I did it right but there's a good chance that I didn't

Similar Threads

  1. HTTP Status 404-The requested resource is not available.
    By DeViLHuNTeR in forum Java Servlet
    Replies: 17
    Last Post: 03-11-2011, 02:40 PM
  2. The requested resource () is not available. Error
    By shyameni in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-17-2010, 09:22 AM
  3. Replies: 0
    Last Post: 10-31-2009, 09:24 AM
  4. The requested resource is not available.
    By ravichandra.t in forum Java Servlet
    Replies: 0
    Last Post: 07-29-2009, 02:18 PM
  5. The requested resource (/Test.war/index.jsp) is not available.
    By rameshraj in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 04-05-2009, 11:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •