Results 1 to 4 of 4
- 06-23-2011, 08:32 AM #1
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
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:
My java code 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>
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 helpJava 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"; } }
- 06-23-2011, 09:52 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Have you mapped your servlet to that name in the web.xml?
- 06-23-2011, 11:44 AM #3
Member
- Join Date
- Nov 2008
- Posts
- 3
- Rep Power
- 0
look at the web.xml
there should be url-pattren and mapping tag .
check wheter it is corret.
- 06-23-2011, 09:31 PM #4
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
Sorry, I forgot to show the xml code as well. the xml code is
I thought I did it right but there's a good chance that I didn'tJava 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>
Similar Threads
-
HTTP Status 404-The requested resource is not available.
By DeViLHuNTeR in forum Java ServletReplies: 17Last Post: 03-11-2011, 02:40 PM -
The requested resource () is not available. Error
By shyameni in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 03-17-2010, 09:22 AM -
use Servlet submit the form to receive a form for the Chinese but it shows the garble
By dmt198704 in forum Java ServletReplies: 0Last Post: 10-31-2009, 09:24 AM -
The requested resource is not available.
By ravichandra.t in forum Java ServletReplies: 0Last Post: 07-29-2009, 02:18 PM -
The requested resource (/Test.war/index.jsp) is not available.
By rameshraj in forum JavaServer Faces (JSF)Replies: 1Last Post: 04-05-2009, 11:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks