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/lib/c.tld</taglib-location>
 </taglib>
 <taglib>
    <taglib-uri>/spring</taglib-uri>
    <taglib-location>/WEB-INF/lib/spring.tld</taglib-location>
  </taglib>

 <servlet>
    <servlet-name>rentaBikeApp</servlet-name>
    <servlet-class>
      org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
    <servlet-name>rentaBikeApp</servlet-name>
    <url-pattern>*.bikes</url-pattern>
 </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.ArrayListRentABike">
      <property name="storeName"><value>Bruce's Bikes</value></property>
   </bean>
   <bean id="bikesController" class="com.springbook.BikesController">
      <property name="facade"><ref bean="rentaBike"/></property>
   </bean>
   <bean id="editBikeController" class="com.springbook.EditBikeController">
      <property name="facade"><ref bean="rentaBike"/></property>
   </bean>
   <bean id="submitBikeController" class="com.springbook.SubmitBikeController">
      <property name="facade"><ref bean="rentaBike"/></property>
   </bean>
   <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
      <property name="mappings">
         <props>
            <prop key="/bikes.bikes">bikesController</prop>
            <prop key="/editBike.bikes">editBikeForm</prop>
            <prop key="/newBike.bikes">editBikeForm</prop>
         </props>
      </property>
   </bean>
   <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="viewClass">
         <value>org.springframework.web.servlet.view.JstlView</value>
      </property>
      <property name="suffix">
         <value>.jsp</value>
      </property>
   </bean>
   <bean id="bikeValidator" class="com.springbook.BikeValidator"/>
   <bean id="editBikeForm" class="com.springbook.SubmitBikeController">
      <property name="sessionForm"><value>true</value></property>
      <property name="commandName"><value>bike</value></property>
      <property name="commandClass"><value>com.springbook.Bike</value></property>
      <property name="validator"><ref bean="bikeValidator"/></property>
      <property name="formView"><value>editBike</value></property>
      <property name="successView"><value>bikes.bikes</value></property>
      <property name="facade"><ref bean="rentaBike"/></property>
   </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.ArrayListRentABike">
            <property name="storeName"><value>"Bruce's Bikes"</value></property>
      </bean>
      
      <bean id="commandLineView" class="com.springbook.CommandLineView">
            <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.






tlDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
EditBikeController  should be return viewname as bikes, not bikes.jsp
0
tlDeveloperAuthor Commented:

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?

0
objectsCommented:
can u post com.springbook.EditBikeController
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

tlDeveloperAuthor Commented:

EditBikeController.java:



package com.springbook;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class EditBikeController implements Controller {
    private RentABike facade;

    public RentABike getFacade() {
        return facade;
    }

    public void setFacade(RentABike facade) {
        this.facade = facade;
    }

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        if(request.getParameter("bikeSerialNo") == null) {
            System.out.println("bikeSerialNo was null");
            return new ModelAndView("editBike");
        } else {
            System.out.println("bikeSerialNo == " + request.getParameter("bikeSerialNo"));
            Bike bike = facade.getBike(request.getParameter("bikeSerialNo"));
            return new ModelAndView("editBike", "bike", bike);
        }

    }
}
0
objectsCommented:
what does editBike.jsp look like
0
tlDeveloperAuthor Commented:

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>
                    <td>
                        <spring:bind path="bike.manufacturer">
                        <input type="text" name="manufacturer" value="<c:out value="${status.value}"/>"><font color="red"><c:out value="${status.errorMessage}"/></font>
                        </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}"/>"><font color="red"><c:out value="${status.errorMessage}"/></font>
                        </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}"/>"><font color="red"><c:out value="${status.errorMessage}"/></font>
                        </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}"/>"><font color="red"><c:out value="${status.errorMessage}"/></font>
                        </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}"/>"><font color="red"><c:out value="${status.errorMessage}"/></font>
                        </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}"/>"><font color="red"><c:out value="${status.errorMessage}"/></font>
                        </spring:bind>
                    </td>
                </tr>
            </table>
            <input type="submit" value="Submit">
        </form>
    </body>
</html>

0
tlDeveloperAuthor Commented:

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/editBikeController would not be causing the error.  Though, I am a newbie so I could be totally wrong.

0
objectsCommented:
sorry, i was looking at the wrong mapping
can u post can u post com.springbook.BikeController
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tlDeveloperAuthor Commented:

Yes, that had it.  This is the file:

package com.springbook;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;


public class BikesController implements Controller {
    private RentABike facade;

    public RentABike getFacade() {
        return facade;
    }

    public void setFacade(RentABike facade) {
        this.facade = facade;
    }

    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        return new ModelAndView("bikes.jsp", "rentaBike", facade);
    }
}


I changed bikes.jsp to bikes and now it works.  Thank you for your help.

0
objectsCommented:
no worries :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.