Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: RE: [servlets] How my Tomcat can't find JSP?


Message #1 by "Andrew" <andrew@h...> on Tue, 4 Jun 2002 10:33:03 +0100
also worth noting is that anything in WEB-INF directory is kept private and
will not be served over HTTP for security unless you enable it by providing
some kind of mechanism for doing so. Putting your JSPs in the WEB-INF
directory stops them from being accessible. The only reason that Servlets
appear to be available is because there is another servlet that invokes them
when a URL for a servlet is requested.

chanoch

----- Original Message -----
From: "Andrew" <andrew@h...>
To: "Professional Java" <pro_java@p...>
Cc: "Professional Java" <pro_java@p...>
Sent: Tuesday, June 04, 2002 10:33 AM
Subject: [pro_java] RE: [servlets] How my Tomcat can't find JSP?


> Your JSP is like a web page (eg html page) so locate it as you would a
html
> page, not in your web-xml directory:
> So instead of:
> D:\Apache Tomcat 4.0\webapps\login\WEB-INF\jsp\menu.jsp
> Try:
> D:\Apache Tomcat 4.0\webapps\login\jsp\menu.jsp
>
> And modify your dispatcher to point to the new location.  Although a JSP
is
> compiled into a servlet (your containers responsibility), you can treat it
> like a HTML page in terms of location in your web application, that is.
>
> Also Edward:  when you post the same message to different lists, those of
us
> subscribed to more than one list see your message several times making it
> look like spam.  Many of us tend to delete messages such as this so your
> problem gets less attention.  Please post first to the most relevant list
> and wait for a response before cross posting to another list.
>
> Regards,
> Andrew
>
> -----Original Message-----
> From: Edward [mailto:zhangsc@n...]
> Sent: 04 June 2002 09:19
> To: Servlets
> Subject: [servlets] How my Tomcat can't find JSP?
>
>  Hello,
>    I use Tomcat to deploy JSP named "menu.jsp",I want to call JSP from
> Servlet.
> //Servlet named "myservlet.java"
>   public void doPost(HttpServletRequest request,HttpServletResponse
> response)
>      throws ServletException,IOException
>  {
>     .....
>     getServletConfig().getServletContext().getRequestDispatcher
>        ("/login/servlet/jsp/menu.jsp").forward(request,response);
>     ...
>  }
>
> //JSP named "menu.jsp"
> <html>
> <body>
>   <H1>I have recieve your message</H1>
> </body>
> </html>
>
> I put my files into follow directories:
> D:\Apache Tomcat 4.0\webapps\login\WEB-INF\jsp\menu.jsp
> D:\Apache Tomcat 4.0\webapps\login\WEB-INF\classes\myservlet.class
> D:\Apache Tomcat 4.0\webapps\login\WEB-INF\web.xml
> D:\Apache Tomcat 4.0\webapps\login\servlets\index.html
>
> //web.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>     "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
> <web-app>
>     <servlet>
>         <servlet-name>
>            myservlet
>         </servlet-name>
>         <servlet-class>
>            myservlet
>         </servlet-class>
>     </servlet>
>     <session-config>
>      <session-timeout>
>         30
>      </session-timeout>
>     </session-config>
>     <welcome-file-list>
>      <welcome-file>
>         index.html
>      </welcome-file>
>      <welcome-file>
>             menu.jsp
>         </welcome-file>
>     </welcome-file-list>
> </web-app>
>
> When I call menu.jsp from servlet,it got a error:
> Apache Tomcat/4.0.1 - HTTP Status 404 - /menu.jsp
>
> type Status report
> message /login/servlet/jsp/menu.jsp
> description The requested resource (/login/servlet/jsp/menu.jsp) is not
> available.
>
> I have put menu.jsp into D:\Apache Tomcat
> 4.0\webapps\login\WEB-INF\jsp\menu.jsp, Why it still error?
> Thanks in advance!
> Edward
>
> to unsubscribe send a blank email to leave-servlets-1112174I@p...
>
>


  Return to Index