Including JSP fragment file in a JSP
Hi, there,
I'm trying to include a fragment JSP file (with an extension .jspf as suggested by JSP1.2 spec) in a JSP file as follows:
<jsp:include page="/header.jspf"/>
But it looks like OC4J thinks it is a static file and thus all JSP tags are ignored. I have to change the file extension from "jspf" to "jsp" to make it work.
Same thing happens with the RequestDispatcher.include method.
Is there a way to handle this in OC4J such as adding a servlet mapping?
Thanks.
Li
You might consider using an include directive instead of an include action. The "jsp:include" element is the include action. This executes at "run time" as an internal forward from the servlet container. However, an include directive executes at servlet generation time (compile time).
So, instead of doing "jsp:include", you would do the following:
<%@ include file="/stuff.jspf" %>
This should allow your JSP fragment to be compiled into the servlet it is being included from.
Similar Messages
-
How to include a .class file in a jsp page
hi everyone,
i know the syntax as:
<%@ include file = "filename.class" %>
then at run time the server could not find the class file
if i use,
<%@ page import = "FileName.class" %>
then also the same problem persists
& if i use
<jsp:include page = "Relative address"/>
the problem still remains as it is...
please help me out...i am working on developing an EJB application in which client interacts with server's Stateful session bean through a jsp page...it is necessary for me to include the home interface class file in my jsp page.
P.S. do not suggest me to include the class file in a package & then use
<%@ page import = "packageName.ClassFileName" %>
i
Edited by: Ankit_JIITU on 6 Jul, 2008 1:55 AMAnkit_JIITU wrote:
i have already included the remote interface class file by <%@ page import = "University.RemoteInterfaceName" %>in my jsp page ...
if i try to make a new package called test & then include my home interface in that package...i need to import University.*to generate the class file of my home interface ; but the class file generation is not taking place as i am getting the error..
"package University does not exist".How can i overcome this problem. The package University, which you are trying to import, must be in the classpath. If you removed it then you will have to add it back.
i have tried my best..but tell me if there's any possible way of including a class file in the jsp page without involving a package.No, there isn't.
If not,then pls help me to generate the class file of my home interface within a package called test.Read the New To Java Tutorial and understand how packages work.
>
i am assuming that u have a deep knowledge of developing EJB applications. -
Hi,
How do i include an external .js(JavaScript) file into a JSP file?My .js file is located in some package(lets say abc.jar). Below is my application structure:-
jsp
|
->MyJsp.jsp
lib
|
|
abc.jar
|
|
->com.abc.test
|
|
->Test.java
->abc.jsHow do i include "abc.js" file in "MyJsp.jsp" file?
Please help.
Thanks,
Kiran
Edited by: Adimulam on Jun 2, 2008 1:22 PMEven this is also not possible because, the code in that package is developed by DWR and i am just adding it to my lib folder and importing the respective classes. In the same manner i need to include the *.js* file in the JSP.It took me about 3 minutes reading through the [DWR Getting Started|http://getahead.org/dwr/getstarted] page to learn that you don't have to do any of that. Perhaps you should read that page?
-
Included JSP files not seeing JavaScript in main JSP file
Hi All,
I have a JSP page that defines a JavaScript block in it's HEAD block and then includes multiple JSP pages in it's BODY block. Calling a JavaScript function from any of the included JSP pages is met with the following JavaScript error:
JavaScript Error: [unknown origin]:
showBatchDetail is not defined.
I'm not sure what is wrong here since the JSP is generating on the server side and everything is fine by the time it gets to the client side. The entire client side file should be seeing the JavaScript block that was included in the main file.
Any help here would be much appreciated.
Steph.
Some barebones code appears below:
Main.jsp
<HTML>
<HEAD>
<TITLE>UNIT INFO</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function showBatchDetail(batchKey)
var url = "/pditools/html/SfmReports/ShowBatchDetail.jsp"
+ "?batchKey=" + batchKey;
document.location = url;
</SCRIPT>
</HEAD>
<BODY>
<%@include file="ShowBatchSummary.jsp"%>
<%@include file="ShowUnitDefects.jsp"%>
<%@include file="ShowUnitHistory.jsp"%>
</BODY>
</HTML>
ShowBatchSummary.jsp
<TABLE>
<TR>
<TD>
BATCH SUMMARY
<A TARGET="_blank" HREF="JavaScript:showBatchDetail(1000);">(Batch Detail)</A>
</TD>
</TR>
<TR>
Show some data ...
</TR>
</TABLE>The problem is not about include but about link use
----ShowBatchSummary.jsp----
<TABLE>
<TR>
<TD>
BATCH SUMMARY
<A TARGET="_blank" HREF="#" onclick="JavaScript:showBatchDetail(1000);">(Batch Detail)</A>
</TD>
</TR>
<TR>
Show some data ...
</TR>
</TABLE>
-------end of ShowBatchSummary.jsp-------- -
Jsp:include an html file in a subdir
I have the following directory structure and files
$CONTEXT/articles.jsp
$CONTEXT/articles/article1.html
$CONTEXT/articles/images/image01.gif
When I browse to
http://$SERVER/$CONTEXT/articles/article1.html
the article and its image display fine. The file article1.html references the image via an href to "images/image01.gif".
However, when I try to access the article from articles.jsp via a <jsp:include page="articles/article1.html" flush="true"/>, the article1.html can't find its image. Obviously this is a problem with the relative path to the image.
I want to be able to correctly view article1.html from directly browsing it and from including it from articles.jsp. How can I include the article1.html from articles.jsp and somehow allow article1.html to find its images? Is this possible?
Best regards and thanks,
JohnI have just tried what you say doesn't work, but I have no problem getting it to work. You may want to check your syntax.
My directory structure is as follows
SERVERNAME/CONTENT/jspinclude.jsp
SERVERNAME/CONTENT/inc/inc.html
SERVERNAME/CONTENT/inc/images/myimage.gif
my jsp file looks like this:
<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY bgcolor="#FFFFFF" text="#000000">
This is a test of a jsp.include
<jsp:include page="inc/inc.html" flush="true" />
</BODY>
</HTML>
my html file looks like this
<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY bgcolor="#FFFFFF" text="#000000">
<P>This is some sample text</P>
<P><IMG src="images/myimage.gif"> </P>
</BODY>
</HTML>
This seems to work fine. Perhaps the problem exists somewhere else.
Rob -
There are 2 jsp files: main.jsp, process.jsp.
In the main.jsp,
String name="java";
<jsp:include page="process.jsp" flush="true" />
.....In the process.jsp,
String name="abc";
....My problem is the parameter - name have not changed to "abc" .
How can I solve this problem ?
thanks.Hi,
Dont think that it should happen like that, the diffrence between <jsp:include> and <%@ include> is that jsp:include is a dymanic include i.e. the processed contents of the jsp flie are added to your page, while @ include is a static include meaning that the contents are first put together as one big jsp and then the contents are processed.
That is why the original jsp is recompiled, and your server should automatically determine that when a parent jsp is to be recompiled when a included jsp is changed. What server are you using?
And as in jsp:include the processed result (html) is added the variable declairations or manipulations in a child will not be accesable in the parent, while they will be in case of @include.
Hope this helps
Regards
Omer -
Passing parameters to included JSP files using JSF
I have included JSP, which I use in many other JSP files. I want to display message in this included JSP which depends on the information in JSP files which include this JSP. How can I do this without using scriptlets?
Message was edited by:
cheltsovI have one included page in one jsp page(mother page). I have included it by jsp:include tag. The included page consists of two inputText. I need to pass the parameters of the mother page together with the parameters in the included page in the backingBean of the mother page. Hope this one is clearer.
The code snippet in the mother page looks like this
<jsp:include page="/pages/ps/sample_rep2.jsp"/>.
In the sample_rep2.jsp, I have two inputText. How can I pass this in the backingBean of the motherpage.
The sample_rep2.jsp is the included page here. The sample_rep2.jsp looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
<af:panelBox>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
<af:panelBox>
<af:inputText label="User ID" id="userid" value="CDOUGLAS"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
<af:panelBox>
<af:inputText label="User ID" id="userid" />
<af:inputText label="Age" id="age"/>
</af:panelBox> -
Adding a fragment file (*.jspf) to a *.jsp file
Adding a fragment file (*.jspf) to a *.jsp file
What I did:
1. Mkdir Web Pages\pages\common
2. Create a *.jspf in directory
3. Mkdir Web Pages\pages\common
4. Create a *.jsp in directory
5. Select page fragment
Outcome:
My *.jspf file is not shown in the combo list box of the "Select Page Fragment" dialig box, unless I create the *.jspf in the Web Pages directory.
Question:
Why?Since you're talking about "mkdir" etc. it sounds like you're trying to do this outside of the IDE. If so, you should note that a fragment is NOT just a .jspf file! All web forms in Creator have two files: a markup file (.jsp or .jspf) and a backing bean (.java). You must create both, by the same name, in the correct location, for the form to be considered a valid fragment. It's best to do this through the IDE.
In case you did use the IDE and it's still not working, perhaps there's an issue with creating page fragments in subfolders. I know we had some bugs with creating regular forms in subfolders and most of those bugs were fixed but perhaps there are some additional issues for fragments.
-- Tor -
What is the best way to include an xml file in JSP?
I have a jsp page that I need to include an xml file. The xml file
uses an xsl to render the file. What is the best way to include the
xml file and still maintain the structure of the style sheet?
Thanks
Jennifer
The best way is using the tag lib. If you cannot, but you can use JAXP, you can
try
javax.xml.transform.Transformer.transform(Source xmlSource,
Result outputTarget)
throws TransformerException
You construct the transformer with you xsl, use you xml file or DOM to form xmlSource,
and use JSPWriter "out" to form outputTarget (StreamResult). But if your JSP page
generates the xml itself, tag lib is the only way.
[email protected] (Jennifer) wrote:
>[email protected] (Jennifer) wrote in message news:<[email protected]>...
>> I have a jsp page that I need to include an xml file. The xml file
>> uses an xsl to render the file. What is the best way to include the
>> xml file and still maintain the structure of the style sheet?
>>
>> Thanks
>>
>> Jennifer
>
>Or is there a way to parse the xml file with the jsp page to display
>the information. I cannot use the Java Standard Tag Libraries as the
>version of iplanet we are running does not support the JSTL
>
>Thanks
>
>Jennifer
-
Jsp:include of html file not working
Hi
I wrote:
<jsp:include page="include.html" />
<% pageContext.include("include.html"); %>
in my jsp, but there is no output and no error message.
What could be the problem?
If I include include.jsp it works.
Does jsp:include only work with jsp, not with html???
I am wondering whether our servlet registrations could be responsible. We have:
weblogic.httpd.defaultServlet=*.jsp
weblogic.httpd.register.*.jsp=weblogic.servlet.JSPServlet
weblogic.httpd.register.*.htm=weblogic.servlet.FileServlet
weblogic.httpd.register.*.html=weblogic.servlet.FileServlet
so that the default servlet is the JSPServlet, not the ServletServlet. We don't
want to use the ServletServlet because it can deliver source code.
What we want to do is a dynamic including of a file, like so:
<% String s = ...; %>
<jsp:include page="<%= s %>" />
Thanks for any help.
Alex
By changing the weblogic servlets that are registered, I can get it to work. The
combination that works is:
weblogic.httpd.defaultServlet=file
weblogic.httpd.register.*.jsp=weblogic.servlet.JSPServlet
weblogic.httpd.register.file=weblogic.servlet.FileServlet
I am surprised that it doesn't work if *.html is mapped explicitly to the FileServlet
(which would leave the defaultServlet unused). Why is that?
And why can't I map defaultServlet to "weblogic.servlet.FileServlet" directly,
without the intervening virtual name "file"?
What are the security implications of having FileServlet as the default servlet?
Thanks
Alex
-
Listing files on the webcontent directory that including .jsp files
Hi ,
I want to list all files on the directory that including .jsp files . How can I do this ?
�f I use the following code in the jsp:
java.io.File file = new java.io.File(".");
String[] files= file.list();
it returns me application server 's directory files. But I want to see webcontent directory files.You can use the method of ServletContext - getRealPath() to turn a website relative location into a real place on disk.
In a generic way:
<%
String dir = application.getRealPath(request.getServletPath());
File jspFile = new File(dir);
File jspDir = jspFile.getParentFile();
File[] files = jspDir.listFiles();
%>Cheers,
evnafets -
How do I add an included jsp to my project and not get a compile error?
Hi,
I have a project with some included jsp's however if I add them to the project, when I build I get a compile error as the jsp uses variables from the calling jsp.
Any ideas on how to get round this.
Thanks
DMThere are two main ways that I deal with this problem (yeah, it sucks, but it sort of makes sense that it happens...) (I presume you're talking static include here...)
#1 - name the included file with an extension that JDev will not try to compile (.jspf - for JSP Fragment - is common) Then it will be compiled in with the including page, but won't gag the project compilation. Advantage - it works, and you find out at compile time if you hosed up the variable reference. Disadvantage: JDev tries really, really, really hard to keep you from naming a JSP file with an extension of .jspf I normally create the .jsp file in JDev, remove it from the project, rename the file outside of JDeveloper, then add it back to the project - pain in the butt, but it works (and you probably aren't building scads of these included files...)
#2 - add the variable to be referenced to the pageContext implicit object as an attribute in your including page (ex, <% pageContext.setAttribute("myVar", myVar); %>), then reference that attribute in your included JSP (ex, <%= pageContext.getAttribute("myVar") %>) . It will compile fine (as the compiler has no way of knowing if the pageContext attribute actually exists, it just sees that the syntax is good and motors along merrily. Advantage: don't have to have differently named JSP files (which isn't actually a big deal). Disadvantage: You hvae to add the variable to the pageContext (and you have to always add Object derivatives, as primitives won't go into a hash) and you don't find out if you screwed the variable up until runtime (when it tries the getAttribute, which could return null if you didn't properly set it to start with) vs at compile-time w/ the direct reference.
HTH!
Jim -
I am having a problem relacing the include file of let's call it a
header.jsp in a menu page named menu.jsp.
So in my header.jsp file let's say I do something simple like
<table>
<tr><td><jato:href name="first">First Option
</jato:href></td></tr></table>
and so on....
And in my main.jsp I have a simple include at the top of my page
like so
<html
<body>
<%include file=header.jsp%>
etc.
Now when JRun 3.0 makes the include replacement, it seems to have a
problem where it tells me
Servlet error 500
com.iplanet.jato.view href : taglib navigation not found
BUT when I take out the jato tags in the include file...I can get
JRun to make the replacement perfectly....
Does anyone else have this problem and if so how did you get around
it?Sorry to bother you again, but I couldn't find anything that looked strange
is this file. Can you send us the original file at our personal email
addresses? I'd like to see exactly where the compilation error occurs and
it's not possible with the file inlined here.
todd.fast@e...
michael.frisino@s...
Thanks,
Todd
----- Original Message -----
From: <suket@u...>
Sent: Wednesday, January 17, 2001 2:02
Subject: [iPlanet-JATO] Re: include jsp tags
Hi Mike,
Both of the jsp files (pgHelp.jsp and pgFooter.jsp)
are in the same folder. I removed the IPP/ipp portion in the
include directive but still giving the same err.
iam using Allair Jrun 3.0.
Here is the intermediary generated Jsp file
/ Generated by JRun, do not edit
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import allaire.jrun.jsp.JRunJSPStaticHelpers;
public class jrun__IPP__ipp__pgHelp2ejsp13 extends
allaire.jrun.jsp.HttpJSPServlet implements
allaire.jrun.jsp.JRunJspPage
private ServletConfig config;
private ServletContext application;
private Object page = this;
private JspFactory __jspFactory = JspFactory.getDefaultFactory();
public void _jspService(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, java.io.IOException
if(config == null) {
config = getServletConfig();
application = config.getServletContext();
response.setContentType("text/html; charset=ISO-8859-1");
PageContext pageContext = __jspFactory.getPageContext(this,
request, response, null, true, 8192, true);
JspWriter out = pageContext.getOut();
HttpSession session = pageContext.getSession();
try {
out.print("\r\n\r\n");
IPP.ipp.pgHelpViewBean viewBean = (IPP.ipp.pgHelpViewBean)
pageContext.getAttribute("viewBean", PageContext.REQUEST_SCOPE);
if(viewBean == null) {
if(JRunJSPStaticHelpers.getAndSetBean(pageContext,
"viewBean", IPP.ipp.pgHelpViewBean.class
, PageContext.REQUEST_SCOPE, 3)) {
viewBean = (IPP.ipp.pgHelpViewBean)pageContext.getAttribute
("viewBean", PageContext.REQUEST_SCOPE);
} else {
viewBean = (IPP.ipp.pgHelpViewBean)pageContext.getAttribute
("viewBean", PageContext.REQUEST_SCOPE);
pageContext.setAttribute("viewBean",viewBean);
out.print("\r\n");
com.iplanet.jato.taglib.UseViewBeanTag useViewBean__4_1 =
(com.iplanet.jato.taglib.UseViewBeanTag)
JRunJSPStaticHelpers.createTagHandler(pageContext,
"com.iplanet.jato.taglib.UseViewBeanTag");
useViewBean__4_1.setPageContext(pageContext);
useViewBean__4_1.setParent(null);
useViewBean__4_1.setClassName("IPP.ipp.pgHelpViewBean");
int useViewBean__4_1_startVal = useViewBean__4_1.doStartTag();
JRunJSPStaticHelpers.checkStartVal
("com.iplanet.jato.taglib.UseViewBeanTag",useViewBean__4_1_startVal,Bo
dyTag.EVAL_BODY_INCLUDE,4);
if(useViewBean__4_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {
com.iplanet.jato.view.ContainerView currentView =
(com.iplanet.jato.view.ContainerView)pageContext.getAttribute
("currentView");
com.iplanet.jato.view.TiledView currentTiledView =
(com.iplanet.jato.view.TiledView)pageContext.getAttribute
("currentTiledView");
out.print("\r\n<HTML>\r\n<HEAD><!--jato:text name=\"stTemp\"
fireDisplayEvents=\"true\" escape=\"true\" /--><!-- Added Temporarily
by ravindran on 8th jan 2001 -->\r\n");
com.iplanet.jato.taglib.TextFieldTag textField__7_1 =
(com.iplanet.jato.taglib.TextFieldTag)
JRunJSPStaticHelpers.createTagHandler(pageContext,
"com.iplanet.jato.taglib.TextFieldTag");
textField__7_1.setPageContext(pageContext);
textField__7_1.setParent(useViewBean__4_1);
textField__7_1.setSize("20");
textField__7_1.setMaxLength("20");
textField__7_1.setFireDisplayEvents("true");
textField__7_1.setName("tbUserID");
textField__7_1.doStartTag();
if(textField__7_1.doEndTag() == Tag.SKIP_PAGE) {
if(true) return;
out.print("\r\n<TITLE>pgHelp</TITLE>\r\n</HEAD>\r\n<body BGCOLOR=
\"white\" bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=
\"#800080\" alink=\"#FF0000\">\r\n");
com.iplanet.jato.taglib.FormTag form__11_1 =
(com.iplanet.jato.taglib.FormTag)JRunJSPStaticHelpers.createTagHandler
(pageContext, "com.iplanet.jato.taglib.FormTag");
form__11_1.setPageContext(pageContext);
form__11_1.setParent(useViewBean__4_1);
form__11_1.setMethod("post");
form__11_1.setName("pgHelp");
int form__11_1_startVal = form__11_1.doStartTag();
JRunJSPStaticHelpers.checkStartVal
("com.iplanet.jato.taglib.FormTag",form__11_1_startVal,BodyTag.EVAL_BO
DY_INCLUDE,11);
if(form__11_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {
out.print("\r\n");
if(form__11_1.doEndTag() == Tag.SKIP_PAGE) {
if(true) return;
out.print("\r\n");
com.iplanet.jato.taglib.UseContainerViewTag view__1_1 =
(com.iplanet.jato.taglib.UseContainerViewTag)
JRunJSPStaticHelpers.createTagHandler(pageContext,
"com.iplanet.jato.taglib.UseContainerViewTag");
view__1_1.setPageContext(pageContext);
view__1_1.setParent(null);
view__1_1.setName("IPP.ipp.pgFooterViewBean");
int view__1_1_startVal = view__1_1.doStartTag();
JRunJSPStaticHelpers.checkStartVal
("com.iplanet.jato.taglib.UseContainerViewTag",view__1_1_startVal,Body
Tag.EVAL_BODY_INCLUDE,1);
if(view__1_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {
currentView = (com.iplanet.jato.view.ContainerView)
pageContext.getAttribute("currentView");
currentTiledView = (com.iplanet.jato.view.TiledView)
pageContext.getAttribute("currentTiledView");
com.iplanet.jato.view.ContainerView
IPP.ipp.pgFooterViewBean = (com.iplanet.jato.view.ContainerView)
pageContext.getAttribute("IPP.ipp.pgFooterViewBean");
out.print("\r\n<hr color=red size=2>\r\nfrom new_footer.jsp in
IPP/ipp directory\r\n<font size=\"-2\" face=\"Arial\"><i>Send
comments to <a href=\"mailto:supportdept@a...\">Any
Company</a></i></font>\r\n<hr color=red size=2>\r\n");
com.iplanet.jato.taglib.HiddenTag hidden__6_1 =
(com.iplanet.jato.taglib.HiddenTag)
JRunJSPStaticHelpers.createTagHandler(pageContext,
"com.iplanet.jato.taglib.HiddenTag");
hidden__6_1.setPageContext(pageContext);
hidden__6_1.setParent(view__1_1);
hidden__6_1.setFireDisplayEvents("true");
hidden__6_1.setName("hdFooter");
hidden__6_1.doStartTag();
if(hidden__6_1.doEndTag() == Tag.SKIP_PAGE) {
if(true) return;
out.print("\r\n");
if(view__1_1.doEndTag() == Tag.SKIP_PAGE) {
if(true) return;
out.print("\r\n");
out.print("\r\n</BODY> \r\n</HTML>\r\n");
if(useViewBean__4_1.doEndTag() == Tag.SKIP_PAGE) {
if(true) return;
} catch(Throwable t) {
if(t instanceof ServletException)
throw (ServletException) t;
if(t instanceof java.io.IOException)
throw (java.io.IOException) t;
if(t instanceof RuntimeException)
throw (RuntimeException) t;
throw JRunJSPStaticHelpers.handleException(t,
pageContext);
} finally {
__jspFactory.releasePageContext(pageContext);
public String getServletInfo()
return "pgHelp";
private static final String[] __dependencies__ =
{"/IPP/ipp/pgHelp.jsp",null};
private static final long[] __times__ = {979720473658L,0L};
public String[] __getDependencies()
return __dependencies__;
public long[] __getLastModifiedTimes()
return __times__;
public int __getTranslationVersion()
return 14;
it is generating 2 semicolons automatically..
near pageContext.getAttribute("IPP.ipp.pgFooterViewBean");
regards
ravi
In [email protected], "Mike Frisino" <Michael.Frisino@S...>
wrote:
Hi Suket,
I just retested something very similar to this in 1.0.
Essentially, i took an existing page which included a tiledView.
I moved the TiledView jsp block into an entirely separate jsp file.
I then replace the TiledView jsp block in the original jsp with aninclude
<%@ include file="TiledGetOrders.jsp"%>
It worked like a charm.
So I am not sure what is wrong in your case.
Could be a jrun bug?
I have tested in resin 1.2.1
To do proper analysis, we would need to see
1. The intermediary .java file that the jsp engine creates, andthen tries
to compile.
C:/Program
Files/Allaire/JRun/servers/default/ipp/WEB-INF/jsp/jrun__IPP__ipp__pgHelp2ej
sp.java
Can you send that to us?
Incidentally, although we do not think a problem there would causethe
compile time error you are seeing,
i am curious about your file value.
<%@ include file="/IPP/ipp/pgFooter.jsp"%>I did not need to use a qualified file name, although my includetarget file
was in the same directory as the
page that was including it. What is the file system relationshipbetween
your top level page "pgHelp" and the include
target "pgFooter".
Are they in same or diff directories?
----- Original Message -----
From: <suket@u...>
Sent: Tuesday, January 16, 2001 9:42 PM
Subject: [iPlanet-JATO] Re: include jsp tags
Hi,
We tried to follow the steps described by you to have
dynamic include in a jsp page.
my jsp file content is
<%@p... info="pgHelp" language="java"%>
<%@t... uri="/WEB-INF/jato.tld" prefix="jato"%>
<jsp:useBean id="viewBean" class="IPP.ipp.pgHelpViewBean"
scope="request"></jsp:useBean>
<jato:useViewBean className="IPP.ipp.pgHelpViewBean">
<HTML>
<HEAD>
<jato:textField name="tbUserID" size="20" maxLength="20"
fireDisplayEvents="true" />
<TITLE>pgHelp</TITLE>
</HEAD>
<body BGCOLOR="white" bgcolor="#FFFFFF" text="#000000"
link="#0000FF" vlink="#800080" alink="#FF0000">
<jato:form name="pgHelp" method="post">
</jato:form>
<%@ include file="/IPP/ipp/pgFooter.jsp"%>
</BODY>
</HTML>
</jato:useViewBean>
This is my pgFooter.jsp
<jato:view name="IPP.ipp.pgFooterViewBean">
<hr color=red size=2>
from new_footer.jsp in IPP/ipp directory
<font size="-2" face="Arial"><i>Send comments to <a
href="mailto:<a href="/group/SunONE-JATO/post?protectID=061075104115193209050223163176249165134048139046">supportdept@a...</a>">Any Company</a></i></font>
<hr color=red size=2>
<jato:hidden name="hdFooter" fireDisplayEvents="true" />
</jato:view>
There is no compilation error in pgFooterViewBean and in
pgHelpViewBean.
How ever iam getting a runtime error,
500 Internal Server Error
/ipp/servlet/IPP.ipp.ippServlet:
javax.servlet.ServletException: Compilation error occured:
allaire.jrun.scripting.DefaultCFE:
Errors reported by compiler:C:/Program
Files/Allaire/JRun/servers/default/ipp/WEB-
INF/jsp/jrun__IPP__ipp__pgHelp2ejsp13.java:105:50:105:50: Syntax:
expected instead of this token
What could be the reason for this error message?
We tried the same thing with another approach, instead of using
include directive, we directly copied the code of pgFooter.jsp in
pghelp.jsp.
even that is giving the same error..
<%@p... info="pgHelp" language="java"%>
<%@t... uri="/WEB-INF/jato.tld" prefix="jato"%>
<jsp:useBean id="viewBean" class="IPP.ipp.pgHelpViewBean"
scope="request"></jsp:useBean>
<jato:useViewBean className="IPP.ipp.pgHelpViewBean">
<HTML>
<HEAD>
<jato:textField name="tbUserID" size="20" maxLength="20"
fireDisplayEvents="true" />
<TITLE>pgHelp</TITLE>
</HEAD>
<body BGCOLOR="white" bgcolor="#FFFFFF" text="#000000"
link="#0000FF" vlink="#800080" alink="#FF0000">
<jato:form name="pgHelp" method="post">
</jato:form>
<jato:view name="IPP.ipp.pgFooterViewBean">
<hr color=red size=2>
from new_footer.jsp in IPP/ipp directory
<font size="-2" face="Arial"><i>Send comments to <a
href="mailto:<a href="/group/SunONE-JATO/post?protectID=061075104115193209050223163176249165134048139046">supportdept@a...</a>">Any Company</a></i></font>
<hr color=red size=2>
<jato:hidden name="hdFooter" fireDisplayEvents="true" />
</jato:view>
</BODY>
</HTML>
</jato:useViewBean>
Please give us a feasible solution to solve this problem.
Thx
Ravi
--- In [email protected], "Todd Fast" <Todd.Fast@S...>wrote:
Craig & Eric--
(If you're not interested in the resolution to the problem Craigposted,
please skip ahead to the section in which I describe the
preferred
technique
for including headers and other common content in a JATO page.
This
discussion is very important because I introduce the concept of"view
compostion", in which JATO pages are composed of modular andreusable view
components. This is one of the most powerful new features of
JATO,
and a
capability that simply wasn't possible in NetDynamics.)
Posted Problem Resolution
Craig & Eric, from what I can tell, you are both trying to
include
a full
view bean in a parent page at translation time. This is notpossible, as
you can see from the compiler errors you get. There are
collisions
when
multiple top-level tags are included in the same JSP.
When I said earlier that you needed to use a translation-timeinclude
instead of a run-time include, I was assuming that you were
trying
to
include a fragment of HTML/JSP in the parent page. By
fragment, I
mean HTML
or JSP content that does not declare a view bean or form, but
rather
references views contained within the parent view bean. If youwant to
include a full page (JSP + ViewBean) in another page, then you'dneed to use
a run-time include. A run-time include temporarily pauses therendering of
the current page, and sends the full request to the included
page
as if it
were a separate client request. The resulting content from theincluded
page is inlined into the parent page's content, and processing
of
the parent
page then continues.
Now I realize after thinking about it a bit that we may not have
sufficiently provided for full page includes because of some
late-
breaking
changes in the request context handling. After some basic
testing,
it
appears that if you try to include one JATO page in another byreferencing
the JSP, the included page will cause a class cast exception tooccur.
There may also be problems because the request context on theincluded page
will not have been set. In any case, full JATO page inclusionlooks like
it's an issue we're going to have to address with some fixes
before
it will
work properly. My apologies. (One workaround if this is
necessary
is to
make the included view bean a child view of the parent view
bean.
I won't
go into that however).
How to Include Common Content
Now, on to the discussion of the preferred way of including
common
content
in a JATO page. Let's say you have a common header you want toinclude in
one or more of your JATO pages. Because of the issue I notedabove, and the
fact that the header is not really independently displayable,
you
don't want
to do a run-time include (which, remember, would necessitateincluding a
full JATO page).
Instead, you should include the header as an HTML/JSP fragmentusing a
translation-time include. Depending on whether your header hasdynamic
information, you can do one of two things. If the header is
just
static
content and/or set of links, you can just reference the HTMLfragment in the
parent HTML directly, and you won't need any kind of view or
view
bean to
back it, or any reference to anything in JATO.
If you need some dynamic info in the header, like the module URLfor a link,
you can reference the parent page's view bean for this
information
by simply
including references to the parent page's implicit JSP variables(viewBean,
currentVIew, and currentTiledView). For example:
Parent JSP:
<jsp:useBean id="viewBean" class="..."scope="request"></jsp:useBean>
<jato:useViewBean className="..." fireChildDisplayEvents="true">
<%@ include file="MyInclude.jsp" %>
</jato:useViewBean>
Included content (MyInclude.jsp):
... viewBean.getRequestContext().getModuleURL() ...
The final HTML with the included content would then look like
this:
<jsp:useBean id="viewBean" class="..."scope="request"></jsp:useBean>
<jato:useViewBean className="..." fireChildDisplayEvents="true">
... viewBean.getRequestContext().getModuleURL() ...
</jato:useViewBean>
MyInclude.jsp will be inlined in the parent JSP before it istranslated to a
servlet. Note that it does not include the full HTML tags
normally
found in
an HTML file--there are no <html>, <head>, or <body> tags
because
it is not
expected to be used outside of an include page. In effect,
this is
the
equivalent of a server-side include (SSI).
Now, if you need truly dynamic info in the header, like say youwant to
display the user's name and SSN, then you'd likely want to
embed a
child
view in the parent view bean which will encapsulate & provide
the
necessary
information. This is in contrast to actually making these
fields
direct
children of the the parent view bean, which would be a tedious
and
error
prone task on every page you wanted to include this information.Let me try
to contrast these two approaches with a diagram of parent-child
relationships:
Here's the bad way:
ParentViewBean (ViewBean)
|
+-- UserFirstName (StaticTextField)
|
+-- UserSSN (StaticTextField)
In this situation, you'd need to provide the logic to populatethese fields
in every view bean on which they appeared. This is tedious andessentially
eliminates the "common"-ness of the content (this is also whatNetDynamics
forced people to do).
Now, the better way:
ParentViewBean (ViewBean)
|
+-- MyHeaderView (MyHeaderView.java)
|
+-- UserFirstName (StaticTextField)
|
+-- UserSSN (StaticTextField)
In the better way, you can see that the header information isencapsulated
in an instance of "MyHeaderView", which is a subclass ofContainerViewBase
or one of the other ContainerView subtypes. The population of
the
data
fields is encapsulated in that view, and the parent view need
not
know
anything about what's actually being displayed by that view.
Thus, you can see that MyHeaderView, in conjunction with a
snippet
of JSP
content in a companion file, is completely modular and can beembedded in
any parent view bean on which you want the header to appear.
The
only
requirement is then to include MyHeaderView as a child view of
the
parent
view bean, and to include the correct JSP content that
references
that child
view.
The included JSP content would now look something like this:
<jato:view name="MyHeaderView">
<table>
<tr><td>... <jato:staticText name="UserFirstName"/>
...</td></tr>
<tr><td>... <jato:staticText name="UserSSN"/> ...</td></tr>
</table>
</jato:view>
If we now included this content in the parent JSP from furtherabove, we get
the following as the JSP content before it is translated into aservlet:
<jsp:useBean id="viewBean" class="..."scope="request"></jsp:useBean>
<jato:useViewBean className="..." fireChildDisplayEvents="true">
<jato:view name="MyHeaderView">
<table>
<tr><td>... <jato:staticText name="UserFirstName"/>
...</td></tr>
<tr><td>... <jato:staticText name="UserSSN"/> ...</td></tr>
</table>
</jato:view>
</jato:useViewBean>
Ultimately, this technique is called "view compostion" or "view
aggregation", and is one of the major new features of JATO. Youcan now
define reusable view components and embed them in multiple viewcontainers,
on the same page or on different pages. Each page acts as a
frame,
in which
you provide the contents from modular components. Using thistechnique, you
can develop reusable view classes and chunks of JSP that can bearbitrarily
combined into complex pages.
I know this is a long and rambling discussion, but I hope I've
made
myself
at least partly clear. I'm more than happy to clarify anything
or
elaborate
more. Please let me know.
Todd
Todd Fast
Senior Engineer
Sun/Netscape Alliance
todd.fast@e...
[email protected]
[email protected] -
How to access a variable from a dynamically included JSP page
I have a jsp (say main.jsp) using the following in its code :
<jsp:include page="menu.jsp" flush="true" />
I have a variable in menu.jsp which I would like to use in my main.jsp.
How do I get the value of the variable defined in menu.jsp ?
I called this variable in menu.jsp, Public, but this didnot help me use the value of that variable in main.jsp
Any help is highly appreciated.. thnks a lotI do notice the variable var1 has the value populated - in menu.jsp - (from View -->
Source in the browser) but for some reason not able to use it in main.jspI'm not quite sure of the way your jsps are structured from your code snippet but I think there is something to be aware of here that may be part of your problem, namely the difference between the include directive and the include action.
You are currently using the include action, this treats the included resource as a dynamic object - i.e. a request is sent to that resource and the resulting response is included in your page. So when you think of what there is no java variable actually included - you'll just get the resulting HTML that is generated by menu.jsp
The include directive, as in <%@include file=�menu.jsp � %>, on the other hand treats the resource as a static object. This means the actual bytes in the included resource are inserted into the including jsp and then the result of that is compiled and processed, effectively you are cutting and pasting the menu.jsp into your calling jsp. In this case the variable would be available to the calling jsp.
However this approach does bring other difficulties that may break your current code, you'll just have to try it and see what happens.
Hope that's relevant to your problem,
Matt -
Custom tag in included JSP page cause exception (WLS 5.1 SP 9)
An application use custom tags (JSP Tag extensions) in JSP page
included into another JSP page by means <jsp:include> instruction.
After we had installed Service Pack 9 for Weblogic 5.1
browser's call of including JSP began show an error.
When I remove Weblogic510sp9.jar and Weblogic510sp9boot.jar
references from startWebLogic.cmd, the error diagnostic disappear.
Is Service Pack Number 9 wrong?
==========================
Web browser diagnostic:
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling
the request.
==========================
Console diagnostic:
Tue Jun 05 17:40:14 MSD 2001:<I> <WebAppServletContext-dscat> looking for taglib
uri /exttags.tld as resource /WEB-INF/e
xttags.tld in Web Application root:
Tue Jun 05 17:40:15 MSD 2001:<I> <WebAppServletContext-dscat> Generated java file:
C:\weblogic\dscat\WEB-INF\_tmp_war_ds
cat\jsp_servlet\_jsp\_opos\_catalog.java
Tue Jun 05 17:40:25 MSD 2001:<E> <WebAppServletContext-dscat> Servlet failed with
Exception
java.lang.VerifyError: (class: jsp_servlet/_jsp/_opos/_catalog, method: _jspService
signature: (Ljavax/servlet/http/Http
ServletRequest;Ljavax/servlet/http/HttpServletResponse;)V) Register 12 contains
wrong type
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:469)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java,
Compiled Code)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:442)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:228)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:115)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:138)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
==========================
Including JSP file:
<%@ include file="catalog_real.jsp" %>
==========================
Included JSP file:
<%@ taglib uri="/exttags.tld" prefix="dscat" %>
<dscat:pageheader>Catalog header</dscat:pageheader>
==========================
Tag extansions library (WEB-INF/exttags.tld file):
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>dscat</shortname>
<tag>
<name>pageheader</name>
<tagclass>ru.ibs.xbcat.view.tag.PageHeader</tagclass>
</tag>
</taglib>
==========================
Class PageHeader:
package ru.ibs.xbcat.view.tag;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class PageHeader extends BodyTagSupport {
public int doStartTag() throws javax.servlet.jsp.JspException {
return BodyTag.EVAL_BODY_TAG;
public int doAfterBody() throws javax.servlet.jsp.JspException {
return(SKIP_BODY);
Are you using Jikes? See if this helps ...
http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=article&group=weblogic.developer.interest.jsp&item=6287&utag=
Mike
"Radik Usmanov" <[email protected]> wrote:
>
>An application use custom tags (JSP Tag extensions) in JSP page
>included into another JSP page by means <jsp:include> instruction.
>
>After we had installed Service Pack 9 for Weblogic 5.1
>browser's call of including JSP began show an error.
>When I remove Weblogic510sp9.jar and Weblogic510sp9boot.jar
>references from startWebLogic.cmd, the error diagnostic disappear.
>
>Is Service Pack Number 9 wrong?
>==========================
>Web browser diagnostic:
>
>Error 500--Internal Server Error
>From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
>10.5.1 500 Internal Server Error
>The server encountered an unexpected condition which prevented it from
>fulfilling
>the request.
>
>==========================
>Console diagnostic:
>
>Tue Jun 05 17:40:14 MSD 2001:<I> <WebAppServletContext-dscat> looking
>for taglib
>uri /exttags.tld as resource /WEB-INF/e
>xttags.tld in Web Application root:
>Tue Jun 05 17:40:15 MSD 2001:<I> <WebAppServletContext-dscat> Generated
>java file:
>C:\weblogic\dscat\WEB-INF\_tmp_war_ds
>cat\jsp_servlet\_jsp\_opos\_catalog.java
>Tue Jun 05 17:40:25 MSD 2001:<E> <WebAppServletContext-dscat> Servlet
>failed with
>Exception
>java.lang.VerifyError: (class: jsp_servlet/_jsp/_opos/_catalog, method:
>_jspService
>signature: (Ljavax/servlet/http/Http
>ServletRequest;Ljavax/servlet/http/HttpServletResponse;)V) Register 12
>contains
>wrong type
> at java.lang.Class.newInstance0(Native Method)
> at java.lang.Class.newInstance(Unknown Source)
> at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:469)
> at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java,
>Compiled Code)
> at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:442)
> at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:228)
> at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:200)
> at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:115)
> at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:138)
> at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
> at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
> at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
> at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
> at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
>Code)
>
>==========================
>Including JSP file:
>...
> <%@ include file="catalog_real.jsp" %>
>...
>
>==========================
>Included JSP file:
>...
> <%@ taglib uri="/exttags.tld" prefix="dscat" %>
>...
><dscat:pageheader>Catalog header</dscat:pageheader>
>...
>==========================
>Tag extansions library (WEB-INF/exttags.tld file):
>
><?xml version="1.0" encoding="ISO-8859-1" ?>
><!DOCTYPE taglib
> PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
> "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
>
><taglib>
> <tlibversion>1.0</tlibversion>
> <jspversion>1.1</jspversion>
> <shortname>dscat</shortname>
>
> <tag>
> <name>pageheader</name>
> <tagclass>ru.ibs.xbcat.view.tag.PageHeader</tagclass>
> </tag>
>
></taglib>
>==========================
>Class PageHeader:
>
>package ru.ibs.xbcat.view.tag;
>
>import java.io.*;
>import javax.servlet.jsp.*;
>import javax.servlet.jsp.tagext.*;
>
>public class PageHeader extends BodyTagSupport {
>
> public int doStartTag() throws javax.servlet.jsp.JspException {
> return BodyTag.EVAL_BODY_TAG;
> }
>
> public int doAfterBody() throws javax.servlet.jsp.JspException {
> ...
> return(SKIP_BODY);
> }
>}
>
Maybe you are looking for
-
MacBook Air heats up quickly, is slow, freezes
Hi there. My MBA has recently started acting up -- CPU gets pegged and fan spins up to max with seemingly no load. Freezes on occasion -- just basically sluggish and sickly performance. Report follows. Any advice would be very much appreciated: Probl
-
Ipod/itunes -48 error message when syncing.
HELP! When trying to sync the ipod with itunes, I am receiving an error message. The error message states: ipod can't be synced. An unknown error occurred (-48). I've tried reinstalling itunes and repairing damaged files on the computer. I don't know
-
Itunes doesnt detect my device
on connecting my ipad mini to windows 7 laptop itunes doesnt open automatically now how to sync music and apps?????
-
Negotiating a port number from the OS
All the socket classes require a port number to be specified. No problem, except as one of the requirements at work, I need to make a server that negotiates with the OS to receive a free port number. I can not hard code any numbers or receive them fr
-
My iphone is frozen, when I plug it in to itunes to restore, it says Restore and then extracts information, but then it says: Iphone could not be restored. The device cannot be found.