Results 1 to 2 of 2
  1. #1
    esolve is offline Member
    Join Date
    Mar 2015
    Posts
    56
    Rep Power
    0

    Default The requested resource is not available.

    Hi, I'm a newbee

    I tried the following servlet project

    Attachment 7097

    and wanted to visit the servlet by the url "http://localhost:8080/jsptest/serv" (BTW, I created a index.jsp and http://localhost:8080/jsptest/index.jsp is OK)

    but I get

    HTTP Status 404 - /jsptest/serv

    type Status report

    message /jsptest/serv

    description The requested resource is not available.

    Apache Tomcat/7.0.34

    I have carefully examined and look for solutions online for hours, but still can't get a clue




    web.xml

    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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
      <display-name>jsptest</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>
      
      <servlet>
      	<servlet-name> servone</servlet-name>
      	<servlet-class> com.ServOne</servlet-class>  	
      </servlet>
      
      <servlet-mapping>
      	<servlet-name> servone</servlet-name>
      	<url-pattern> /jsptest/serv</url-pattern>
      </servlet-mapping>
    </web-app>

    com.ServOne.java file

    Java Code:
    package com;
    
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.PrintWriter;
    
    /**
     * Servlet implementation class ServOne
     */
    //@WebServlet("/ServOne")
    public class ServOne extends HttpServlet {
    	private static final long serialVersionUID = 1L;
           
        /**
         * @see HttpServlet#HttpServlet()
         */
        public ServOne() {
            super();
            // TODO Auto-generated constructor stub
        }
    
    	/**
    	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    	 */
    	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		// TODO Auto-generated method stub
    		response.setContentType("text/html;charset=gb2312");
    	    PrintWriter out = response.getWriter();
    	    out.println("<HTML>");
    	    out.println("<HEAD>");
    	    out.println("<TITLE>Hello Servlet</TITLE>");
    	    out.println("</HEAD>");
    	    out.println("<BODY>");
    	    out.println("<B>Hello, World !</B>");
    	    out.println("</BODY>");
    	    out.println("</HTML>");
    	    out.close();
    	}
    
    	/**
    	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    	 */
    	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		// TODO Auto-generated method stub
    		doGet(request, response);
    	}
    
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: The requested resource is not available.

    What is the name of the folder that your web app is installed to under tomcat?

    I suspect that this:
    Java Code:
    <url-pattern> /jsptest/serv</url-pattern>
    should be this:
    Java Code:
    <url-pattern>/serv</url-pattern>
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 8
    Last Post: 03-25-2015, 12:54 AM
  2. The requested resource () is not available
    By hartmannr76 in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 05-31-2012, 07:39 AM
  3. The requested resource (/InsertDataAction/) is not available.
    By prashanthbokkala in forum Java Servlet
    Replies: 0
    Last Post: 02-22-2012, 11:03 AM
  4. 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
  5. The requested resource is not available.
    By ravichandra.t in forum Java Servlet
    Replies: 0
    Last Post: 07-29-2009, 02:18 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
  •