aspose file tools*
The moose likes JSP and the fly likes response.sendRedirect problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "response.sendRedirect problem" Watch "response.sendRedirect problem" New topic
Author

response.sendRedirect problem

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
server: tomcat 5.5.7

I have the following file (index.jsp) in the root of my_webapp

<% response.sendRedirect("login.jsp"); %>

when I access the my_webapp directory (without specifying any file), I am supposed to call undex.jsp, hence be redirected to login.jsp. Am I right???

However, I only get the following exception (please advise):


HTTP Status 404 - Servlet org.apache.jsp.index_jsp is not available

type Status report

message Servlet org.apache.jsp.index_jsp is not available

description The requested resource (Servlet org.apache.jsp.index_jsp is not available) is not available.
Apache Tomcat/5.5.7


We must know, we will know. -- David Hilbert
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Where are you putting your JSPs?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Just one level above the WEB-INF folder of my app. Other JSPs in the same place work okay.
Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213
if the index.jsp is inside your web-app root directory, and if you access

http://localhost:8080/myapp/

it should work.


Also check out the welcome file list in the web.xml

Regard


Sarath Mohan
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
something does not work.

tomcat on local machine, when I access: http://localhost:8080/resumail/

gives me:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Wrapper cannot find servlet class org.apache.jsp.index_jsp or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:595)

root cause

java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:595)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs.


-------------------------------------------------------------------------

when I access directly http://localhost:8080/resumail/index.jsp

it gives me:

HTTP Status 404 - Servlet org.apache.jsp.index_jsp is not available

type Status report

message Servlet org.apache.jsp.index_jsp is not available

description The requested resource (Servlet org.apache.jsp.index_jsp is not available) is not available.
Apache Tomcat/5.5.7


-------------------------------------------------------------------------


the web.xml of that app (resumail) is:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<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">

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>

<!-- JSPC servlet mappings start -->

<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>

<!-- JSPC servlet mappings end -->

<servlet>
<servlet-name>ch01_06</servlet-name>
<servlet-class>ch01_06</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ch01_06</servlet-name>
<url-pattern>/servlet/ch01_06</url-pattern>
</servlet-mapping>

<!-- jdbc_odbc dsn example -->

<servlet>
<servlet-name>emaildb</servlet-name>
<servlet-class>emaildb</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>emaildb</servlet-name>
<url-pattern>/servlet/emaildb</url-pattern>
</servlet-mapping>

<!-- emailList servlet -->

<servlet>
<servlet-name>emailList</servlet-name>
<servlet-class>emailList</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>emailList</servlet-name>
<url-pattern>/servlet/emailList</url-pattern>
</servlet-mapping>

<!-- verifyUser servlet -->

<servlet>
<servlet-name>verifyUser</servlet-name>
<servlet-class>verifyUser</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>verifyUser</servlet-name>
<url-pattern>/servlet/verifyUser</url-pattern>
</servlet-mapping>

<!-- updateUserEmail servlet -->

<servlet>
<servlet-name>updateUserEmail</servlet-name>
<servlet-class>updateUserEmail</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>updateUserEmail</servlet-name>
<url-pattern>/servlet/updateUserEmail</url-pattern>
</servlet-mapping>

<!-- updateUserPassword servlet -->

<servlet>
<servlet-name>updateUserPassword</servlet-name>
<servlet-class>updateUserPassword</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>updateUserPassword</servlet-name>
<url-pattern>/servlet/updateUserPassword</url-pattern>
</servlet-mapping>

<!-- emailMe servlet -->

<servlet>
<servlet-name>emailMe</servlet-name>
<servlet-class>emailMe</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>emailMe</servlet-name>
<url-pattern>/servlet/emailMe</url-pattern>
</servlet-mapping>

<!-- updateAddressees servlet -->

<servlet>
<servlet-name>updateAddressees</servlet-name>
<servlet-class>updateAddressees</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>updateAddressees</servlet-name>
<url-pattern>/servlet/updateAddressees</url-pattern>
</servlet-mapping>

<!-- addAddressee servlet -->

<servlet>
<servlet-name>addAddressee</servlet-name>
<servlet-class>addAddressee</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>addAddressee</servlet-name>
<url-pattern>/servlet/addAddressee</url-pattern>
</servlet-mapping>

<!-- insertAddressee servlet -->

<servlet>
<servlet-name>insertAddressee</servlet-name>
<servlet-class>insertAddressee</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>insertAddressee</servlet-name>
<url-pattern>/servlet/insertAddressee</url-pattern>
</servlet-mapping>

<!-- insertConfirm servlet -->

<servlet>
<servlet-name>insertConfirm</servlet-name>
<servlet-class>insertConfirm</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>insertConfirm</servlet-name>
<url-pattern>/servlet/insertConfirm</url-pattern>
</servlet-mapping>

<!-- searchAddressees servlet -->

<servlet>
<servlet-name>searchAddressees</servlet-name>
<servlet-class>searchAddressees</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>searchAddressees</servlet-name>
<url-pattern>/servlet/searchAddressees</url-pattern>
</servlet-mapping>


<!-- searchResults servlet -->

<servlet>
<servlet-name>searchResults</servlet-name>
<servlet-class>searchResults</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>searchResults</servlet-name>
<url-pattern>/servlet/searchResults</url-pattern>
</servlet-mapping>

<!-- tempUpload servlet -->

<servlet>
<servlet-name>tempUpload</servlet-name>
<servlet-class>tempUpload</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>tempUpload</servlet-name>
<url-pattern>/servlet/tempUpload</url-pattern>
</servlet-mapping>


</web-app>
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Joseph Sweet:
Just one level above the WEB-INF folder of my app. Other JSPs in the same place work okay.


Are you putting them in TOMCAT_HOME/webapps/ROOT ?

The ROOT app that ships with Tomcat has pre-compiled JSPs that are explicitly mapped in web.xml.
You'll either need to remove the mappings or start your own app under webapps.

The 2nd is the better option.
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
Could it be something really simple, like a mistake in the filename?

-Yuriy
Ivan Tamayo
Ranch Hand

Joined: Aug 13, 2001
Posts: 49
Try

sendRedirect("/index.jsp");
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
I am still stuck... help...
I have the same problem on my local tomcat and on a remote tomcat server.

Yuriy Zilbergleyt - I don't think so.

Ivan Tamayo - didn't work.

Ben Souther - as I said it is in a new app (called resumail) under webapps.
Should I map JSPs in the web.xml ??? I thought only servlets should be mapped.
If they should be mapped, how do all the other JSPs work fine if they are in the same directory as the index.jsp, login.jsp
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

You should not need to map JSPs in web.xml. It sounds like there may be a problem with the sturcture of your web app. Could you describe exactly how you've laid out the folders and files under your context root?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
webapps: the one that comes with tomcat.

then: webapps/resumail, this is my app directory.

inside webapps/resumail there are all the JSPs.

webapps/resumail/WEB-INF/classes is where all the classes are

basically most of the app is working.... the index.jsp does not...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: response.sendRedirect problem