Problem with jsp:include

J

Jon Rasmussen

I have a JSP that uses jsp:include to add some dynamic content.

I am using the following code:

1)
<jsp:include page="/Controller?action=topMenu">
<jsp:param name="top_menu" value="displayHome" />
</jsp:include>

and

2)
<jsp:include page="/generic/topMenu.jsp">
<jsp:param name="top_menu" value="viewDevices" />
</jsp:include>

When running on WebLogic 6.1 SP 5 on Unix, I am encountering problems
with the first piece of code.

In this case, the server executes JSP code that is prior to the
jsp:include tag, and returns the result from the jsp:include tag. The
rest of the page is not returned.

I have also tried to set flush=true, but the result is no different.


Both 1) and 2) run as expected on WebLogic 6.1 SP2 on PC. As far as I
can see from the Javadoc, both these versions of jsp:include should be
valid.



Any solutions or workarounds to the problem are highly appreciated.


Regards,

Jon Rasmussen
 
E

Erwin Moller

Jon said:
I have a JSP that uses jsp:include to add some dynamic content.

I am using the following code:

1)
<jsp:include page="/Controller?action=topMenu">
<jsp:param name="top_menu" value="displayHome" />
</jsp:include>


Why not try this?? :
<jsp:include page="/Controller">
<jsp:param name="top_menu" value="displayHome" />
and

2)
<jsp:include page="/generic/topMenu.jsp">
<jsp:param name="top_menu" value="viewDevices" />
</jsp:include>

When running on WebLogic 6.1 SP 5 on Unix, I am encountering problems
with the first piece of code.

In this case, the server executes JSP code that is prior to the
jsp:include tag, and returns the result from the jsp:include tag. The
rest of the page is not returned.

I have also tried to set flush=true, but the result is no different.


Both 1) and 2) run as expected on WebLogic 6.1 SP2 on PC. As far as I
can see from the Javadoc, both these versions of jsp:include should be
valid.

"as expected" ?
I think it is very nice of Weblogic to do the GET-parsing for you, but I
doubt if it is in the specs that way (I didn't check).

I think Tomcat refuses the *.jsp?param=value coding you used.
Any solutions or workarounds to the problem are highly appreciated.


Regards,

Jon Rasmussen


Good luck.

Reagrds,
Erwin Moller
 
J

Jon Rasmussen

My problem is that I need to include the result from a servlet into a
JSP page.
Is there a better way to do this?

I am considering replacing my code with
<%
request.setAttribute("action", "topMenu");
pageContext.include("/Controller");
%>

If i use the pageContext intead, do I need to worry about issues
regarding flushing etc? Should the rest of the JSP page be processed
after this code has been executed?

Any other ideas?

Cheers,

Jon
 
O

Oscar Kind

Jon Rasmussen said:
My problem is that I need to include the result from a servlet into a
JSP page.
Is there a better way to do this?

Given that your current (failed) attempt uses a jsp:include tag, no.
However, there is a different approach:

<%@ include file="/Controller?action=topMenu" %>

There are a few differences with the jsp:include tag though:

- The included page is evaluated _once_. It cannot contain dynamic content
that must be different on subsequent requests for the including page. If
it does, the contwnt is not refreshed.

- You must create the URI yourself if it contains parameters. But in
that case a dynamic include is probably better.
Note that in your case a different servlet mapping (/ControllerTopMenu)
would suffice.


Oscar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top