tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Hanik - Dev Lists <devli...@hanik.com>
Subject Re: Fw: Servlet problem
Date Mon, 20 Feb 2006 22:23:31 GMT
per your web.xml
http://localhost:8080/WEB-INF/classes/SearchServlet?itemvalue=type+search+criteria+here
should be
http://localhost:8080/searchmatch.jsp?itemvalue=type+search+criteria+here


Filip




Mark Whitby wrote:
> EDIT: I've sent this twice because the first one contained an error in what I wrote.
 Ignore the first one.
>
> Hi all,
>
> Apologies for the stupidity of this email but I'm having a few servlet problems.  I've
created the following SearchServlet.java file, compiled it into a class file using Netbeans
then copied the class file into my WEB-XML/classes file.  
>
> Now for testing the servlet is very limited but when I try to run the jsp page the page
is redirected to http://localhost:8080/WEB-INF/classes/SearchServlet?itemvalue=type+search+criteria+here
and not /searchnone.jsp as specified.  When it's redirected to the first page though all I
get is my error.jsp page which is set up to catch 404 error pages as defined in my web.xml
page.  So it isn't finding something, what I don't know though.
>
> Can anyone tell me where I'm going wrong?
>
> Mark
>
> searchitem.jsp:
>
> <table width="100%"> 
> <tr>
> <td>
>  <p class="subhead">Item Search Page</p>
>  <p>
>   Use this page to search through the different items that we stock.  All searches are
done by 
>
> key words.  If using multiple words please use a comma after every different word.</i>.
>  </p>
>  <p>
>  <FORM ACTION="WEB-INF/classes/SearchServlet" METHOD="GET">
>      <INPUT TYPE="TEXT" NAME="itemvalue" SIZE="100" VALUE="type search criteria here"><br>
>      <INPUT TYPE="SUBMIT">
>  </FORM>
>  </p>
>  <p>
>  <a href="search.jsp">Return to the main search page</a>
>  </p>
>    </td>
>    </tr>
>    </table>
>
> SearchServlet.java
>
> import java.io.*;
> import java.net.*;
>
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class SearchServlet extends HttpServlet {
>
>     public void processRequest(HttpServletRequest request, HttpServletResponse response)
>     throws ServletException, IOException {
>         
>         String address = "/searchnone.jsp";
>         
>         RequestDispatcher dispatcher = request.getRequestDispatcher(address);
>         dispatcher.forward(request, response);
>     }
>     
>     protected void doGet(HttpServletRequest request, HttpServletResponse response)
>     throws ServletException, IOException {
>         processRequest(request, response);
>     }
>     
> void doPost(HttpServletRequest request, HttpServletResponse response)
>     throws ServletException, IOException {
>         processRequest(request, response);
>     }
>     
>
>     public String getServletInfo() {
>         return "Short description";
>     }
> }
>
> web.xml
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app PUBLIC 
> "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
> "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
>
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
>     version="2.4">
>
> <!--
> Specifies the first page that users will come to in the system
> -->
>   <welcome-file-list>
>     <welcome-file>/index.jsp</welcome-file>
>   </welcome-file-list>
>
> <!--
> Specifies the error page that will occur for 404 errors
> -->
>
>   <error-page>
>     <error-code>404</error-code>
>     <location>/error.jsp</location>
>   </error-page>
>
> <!--
> Database connection test
> -->
>
>   <resource-ref>
>       <description>DB Connection</description>
>       <res-ref-name>jdbc/TestDB</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
>   </resource-ref>
>
>
>   <servlet>
>     <servlet-name>SearchServlet</servlet-name>
>     <servlet-class>SearchServlet</servlet-class>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>SearchServlet</servlet-name>
>     <url-pattern>/searchmatch.jsp</url-pattern>
>   </servlet-mapping>
>   <servlet-mapping>
>     <servlet-name>SearchServlet</servlet-name>
>     <url-pattern>/searchmatch.jsp</url-pattern>
>   </servlet-mapping>
>
>
> <!--
> Specifies the security area within the system
> -->
>
>     <security-constraint>
>         <web-resource-collection>
>             <web-resource-name>Secure Area</web-resource-name>
>             <url-pattern>/secure/*</url-pattern>
>             <http-method>GET</http-method>
>             <http-method>POST</http-method>
>         </web-resource-collection>
>         <user-data-constraint>
>             <transport-guarantee>CONFIDENTIAL</transport-guarantee>
>         </user-data-constraint>
>     </security-constraint>
>
>
> </web-app>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message