PDA

View Full Version : controller associated with included jsp not used


ervalerio
Mar 15th, 2006, 10:20 AM
Hi,

i have a jsp file, A.jsp that has an associated controller. inside A, i do a standard inclusion like:

<div id="B">
<%@ include file="/WEB-INF/jsp/B.jsp" %>
</div>

also B has a controller associated, in particular like this:

<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
....
<prop key="/B.htm">BController</prop>
....
</props>
</property>
</bean>

where B controller is supposed to put some vars in the context. the problem occurs when a user accesses A.jsp, and the included B.jsp is included but it can't find needed variables.

any suggestion is very appreciated !

valerio

Cowboy Bob
Mar 15th, 2006, 12:04 PM
Use the JSTL import tag and make it reference your controller and not the raw JSP.

<div id="B">
<c:import url="/WEB-INF/jsp/B.htm"/>
</div>

ervalerio
Mar 15th, 2006, 12:34 PM
what should be the url value ? the jsp i wanted to include is in WEB-INF/jsp/B.jsp

i did the modification you suggested, but i get:

18:29:14,683 WARN PageNotFound:866 - No mapping for [/app-context-name/WEB-INF/jsp/A.jsp] in DispatcherServlet with name 'springapp'

i do have a mapping in my context-file for A...

i also tried (even if I don't like very much a fail-and-retry approach) with:

<c:import url="B.htm"/>

since the mapping in the springapp-controller defines it as I said before
<prop key="/B.htm">BController</prop>

any idea ?

Cowboy Bob
Mar 15th, 2006, 12:44 PM
The URL for <c:import url="B.htm"/> will be the same as if you were doing <a href="B.htm">

So work out how you can navigate to B.htm via a link, then paste it into the import tag.

ervalerio
Mar 16th, 2006, 08:32 AM
the jsp is included..I still have a problem with that: the B.jsp uses some jstl tag lib, but it seems those are not properly used.
in fact, in the source page of B.jsp there are things like:
<c:url value="cercaNotizie.htm"/>

which are still there when the page is rendered..

the inclusion of the jstl libraries is done in the top of A.jsp with the following code:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

and include.jsp looks like this:
<%@ page session="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

any idea ?

Cowboy Bob
Mar 16th, 2006, 09:00 AM
Yeah, you need to include the taglib declaration at the top of every page - including B.jsp

ervalerio
Mar 16th, 2006, 10:34 AM
it worked
thanks