tlDeveloper
asked on
Web browser tries to load page with .jsp.jsp extension rather than .jsp extension in Java web application
I am developing a web app using java tools and Tomcat. I type the following into my browser: http://localhost:7777/bikestore/bikes.bikes , and this is supposed to load the page bikes.jsp but instead I get the following message in my browser:
HTTP Status 404 - /bikes.jsp.jsp
type Status report
message /bikes.jsp.jsp
description The requested resource (/bikes.jsp.jsp) is not available.
Apache Tomcat/5.5.16
Here are some other relevant files:
web.xml:
<!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>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/
</taglib>
<taglib>
<taglib-uri>/spring</tagli
<taglib-location>/WEB-INF/
</taglib>
<servlet>
<servlet-name>rentaBikeApp
<servlet-class>
org.springframework.web.se
</servlet-class>
<load-on-startup>1</load-o
</servlet>
<servlet-mapping>
<servlet-name>rentaBikeApp
<url-pattern>*.bikes</url-
</servlet-mapping>
</web-app>
rentaBikeApp-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="rentaBike" class="com.springbook.Arra
<property name="storeName"><value>Br
</bean>
<bean id="bikesController" class="com.springbook.Bike
<property name="facade"><ref bean="rentaBike"/></proper
</bean>
<bean id="editBikeController" class="com.springbook.Edit
<property name="facade"><ref bean="rentaBike"/></proper
</bean>
<bean id="submitBikeController" class="com.springbook.Subm
<property name="facade"><ref bean="rentaBike"/></proper
</bean>
<bean id="urlMapping" class="org.springframework
<property name="mappings">
<props>
<prop key="/bikes.bikes">bikesCo
<prop key="/editBike.bikes">edit
<prop key="/newBike.bikes">editB
</props>
</property>
</bean>
<bean id="viewResolver" class="org.springframework
<property name="viewClass">
<value>org.springframework
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="bikeValidator" class="com.springbook.Bike
<bean id="editBikeForm" class="com.springbook.Subm
<property name="sessionForm"><value>
<property name="commandName"><value>
<property name="commandClass"><value
<property name="validator"><ref bean="bikeValidator"/></pr
<property name="formView"><value>edi
<property name="successView"><value>
<property name="facade"><ref bean="rentaBike"/></proper
</bean>
</beans>
RentABike-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="rentaBike" class="com.springbook.Arra
<property name="storeName"><value>"B
</bean>
<bean id="commandLineView" class="com.springbook.Comm
<property name="rentaBike"><ref bean="rentaBike" /></property>
</bean>
</beans>
I am unable to figure out why the browser is trying to load bikes.jsp.jsp rather than bikes.jsp. I would greatly appreciate any suggestions. Please let me know if there are other files which I can provide.
EditBikeController should be return viewname as bikes, not bikes.jsp
ASKER
I am unable to find anywhere where I wrote "bikes.jsp". Where do I return the viewname as bikes.jsp? What should I be editting?
can u post com.springbook.EditBikeCon troller
ASKER
EditBikeController.java:
package com.springbook;
import org.springframework.web.se
import org.springframework.web.se
import javax.servlet.http.HttpSer
import javax.servlet.http.HttpSer
public class EditBikeController implements Controller {
private RentABike facade;
public RentABike getFacade() {
return facade;
}
public void setFacade(RentABike facade) {
this.facade = facade;
}
public ModelAndView handleRequest(HttpServletR
if(request.getParameter("b
System.out.println("bikeSe
return new ModelAndView("editBike");
} else {
System.out.println("bikeSe
Bike bike = facade.getBike(request.get
return new ModelAndView("editBike", "bike", bike);
}
}
}
what does editBike.jsp look like
ASKER
editBike.jsp:
<%@ page isELIgnored="false" import="com.springbook.*" %>
<%@ include file="include.jsp" %>
<%@ taglib prefix="spring" uri="/spring" %>
<html>
<head>
<title>
Edit Bike
</title>
</head>
<body>
<h1>Edit Bike</h1>
<form method="POST">
<spring:hasBindErrors name="bike">
<b>Please fix all errors!</b>
</spring:hasBindErrors>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td align="right">Manufacturer
<td>
<spring:bind path="bike.manufacturer">
<input type="text" name="manufacturer" value="<c:out value="${status.value}"/>"
</spring:bind>
</td>
</tr>
<tr>
<td align="right">Model:</td>
<td>
<spring:bind path="bike.model">
<input type="text" name="model" value="<c:out value="${status.value}"/>"
</spring:bind>
</td>
</tr>
<tr>
<td align="right">Frame:</td>
<td>
<spring:bind path="bike.frame">
<input type="text" name="frame" value="<c:out value="${status.value}"/>"
</spring:bind>
</td>
</tr>
<tr>
<td align="right">Serial Number:</td>
<td>
<spring:bind path="bike.serialNo">
<input type="text" name="serialNo" value="<c:out value="${status.value}"/>"
</spring:bind>
</td>
</tr>
<tr>
<td align="right">Weight:</td>
<td>
<spring:bind path="bike.weight">
<input type="text" name="weight" value="<c:out value="${status.value}"/>"
</spring:bind>
</td>
</tr>
<tr>
<td align="right">Status:</td>
<td>
<spring:bind path="bike.status">
<input type="text" name="status" value="<c:out value="${status.value}"/>"
</spring:bind>
</td>
</tr>
</table>
<input type="submit" value="Submit">
</form>
</body>
</html>
ASKER
I am thinking that the error is being caused by something other than the edit pages because the bikes are not being edited yet. bikes.bikes should load bikes.jsp which lists all the available bikes and let's you click one to edit which should then load editBikes.jsp but it is not getting that far so it might be that editBikes/editBikeControll
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, that had it. This is the file:
package com.springbook;
import org.springframework.web.se
import org.springframework.web.se
import javax.servlet.http.HttpSer
import javax.servlet.http.HttpSer
public class BikesController implements Controller {
private RentABike facade;
public RentABike getFacade() {
return facade;
}
public void setFacade(RentABike facade) {
this.facade = facade;
}
public ModelAndView handleRequest(HttpServletR
return new ModelAndView("bikes.jsp", "rentaBike", facade);
}
}
I changed bikes.jsp to bikes and now it works. Thank you for your help.
no worries :)