ttlguk
asked on
jsp include cross-context
Hi guys,
I am facing problem in switcing context.
Context 1:
--------------
JSP Page: callPage.jsp
<%@ taglib uri="/WEB-INF/b2b-jspTagLi b.tld" prefix="ppjsp" %>
....
<ppjsp:listTemplateTaglib type_imp_exp="1" ownerOrgId="<%=orgId%>" userId="<%=userId%>" moduleId="1" includePage="../import/res ultPage.js p" ></ppjsp:listTemplateTagli b>
Context 2:
-------------
JSP Page: resultPage.jsp
My servlet (inside context 2):
--------------
public int doStartTag() throws javax.servlet.jsp.JspTagEx ception{
try{
ListAttributeModel model = new ListAttributeModel();
model.setIncludePage(inclu dePage);
model.setUserId(userId);
model.setModuleId(moduleId );
model.setOwnerOrgId(ownerO rgId);
pageContext.setAttribute(" ListAttrib uteModel", model,PageContext.SESSION_ SCOPE);
pageContext.getPage();
pageContext.include(model. getInclude Page());
StringBuffer sb = new StringBuffer();
sb.append("");
pageContext.getOut().write (sb.toStri ng());
}
catch(java.io.IOException e){
throw new JspTagException("IO Error: " + e.getMessage());
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return EVAL_PAGE;
}
ERROR: File not found.
Context still remain "context 1". I want it change to "context 2" so that resultPage.jsp able to display in callPage.jsp.
Please advise.
Thanks.
I am facing problem in switcing context.
Context 1:
--------------
JSP Page: callPage.jsp
<%@ taglib uri="/WEB-INF/b2b-jspTagLi
....
<ppjsp:listTemplateTaglib type_imp_exp="1" ownerOrgId="<%=orgId%>" userId="<%=userId%>" moduleId="1" includePage="../import/res
Context 2:
-------------
JSP Page: resultPage.jsp
My servlet (inside context 2):
--------------
public int doStartTag() throws javax.servlet.jsp.JspTagEx
try{
ListAttributeModel model = new ListAttributeModel();
model.setIncludePage(inclu
model.setUserId(userId);
model.setModuleId(moduleId
model.setOwnerOrgId(ownerO
pageContext.setAttribute("
pageContext.getPage();
pageContext.include(model.
StringBuffer sb = new StringBuffer();
sb.append("");
pageContext.getOut().write
}
catch(java.io.IOException e){
throw new JspTagException("IO Error: " + e.getMessage());
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return EVAL_PAGE;
}
ERROR: File not found.
Context still remain "context 1". I want it change to "context 2" so that resultPage.jsp able to display in callPage.jsp.
Please advise.
Thanks.
The easy way would be to use JSTL <c:import> tag. What is your web app server ? Is it Tomcat ?
If you don't want to use JSTL then you could use HttpURLConnection.
ASKER
Web server is JBOSS.
plz advise.
Thanks.
plz advise.
Thanks.
I don't use JBOSS. But I still think you should download JSTL from
http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi
and put the two jars in your classpath. Try to use
<c:import url="/directory/resultPage .jsp" context="/context2"/>
But I have a concern. Your resultPage.jsp is coded like a custom tag. Why is that ? rrz
http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi
and put the two jars in your classpath. Try to use
<c:import url="/directory/resultPage
But I have a concern. Your resultPage.jsp is coded like a custom tag. Why is that ? rrz
ASKER
my result page contains a table. this page will retrieve data from db and display. I din't code like a custom tag, it is just normal jsp page.
ASKER
Hie rrz,
What are the 2 jars you mentioned? are they jstl.jsr and standard.jar?
Thanks.
What are the 2 jars you mentioned? are they jstl.jsr and standard.jar?
Thanks.
Yes, those two.
ASKER
Hie rrz,
I already add these two. And, how about *.tld file? I added c.tld and modified web xml.
In the jsp page, I wrote:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import url="/import/importDocumen t.jsp?type _imp_exp=1 &ownerOrgI d=<%=orgId %>&userId= <%=userId% >&moduleId =1" context="/importExport"/>
But, I got the error as below:
org.apache.jasper.JasperEx ception: XML parsing error on file /WEB-INF/c.tld: (line 3, col -1): Element type "taglib" is not declared.
What should I do? Anything wrong?
Please advise.
Thanks.
I already add these two. And, how about *.tld file? I added c.tld and modified web xml.
In the jsp page, I wrote:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import url="/import/importDocumen
But, I got the error as below:
org.apache.jasper.JasperEx
What should I do? Anything wrong?
Please advise.
Thanks.
>I added c.tld and modified web xml.
No, don't do that. The tlds are in the jstl.jar and you don't have to worry about them. Change your web.xml back.
No, don't do that. The tlds are in the jstl.jar and you don't have to worry about them. Change your web.xml back.
ASKER
line 3 is this statement:
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
ASKER
oh .. already edited back.
i copied these 2 jar files into C:\JBoss-2.4.4_Tomcat-4.0. 1\jboss\li b\ext folder.
JSP PAGE:
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import url="/import/importDocumen t.jsp?type _imp_exp=1 &ownerOrgI d=<%=orgId %>&userId= <%=userId% >&moduleId =1" context="/importExport"/>
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++ ++
ERROR:
------------
org.apache.jasper.JasperEx ception: This absolute uri (http://java.sun.com/jsp/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application
What is the problem?
plz advise.
thanks.
i copied these 2 jar files into C:\JBoss-2.4.4_Tomcat-4.0.
JSP PAGE:
++++++++++++++++++++++++++
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import url="/import/importDocumen
++++++++++++++++++++++++++
ERROR:
------------
org.apache.jasper.JasperEx
What is the problem?
plz advise.
thanks.
I don't use JBoss, so I don't know.
>C:\JBoss-2.4.4_Tomcat-4.0 .1\jboss\l ib\ext folder.
Is that in the classpath for your contexts ?
All I know is that in Tomcat we put them into C:\Tomcat\common\lib but you should ask someone that knows JBoss. I am going to bed now. Good night. rrz
>C:\JBoss-2.4.4_Tomcat-4.0
Is that in the classpath for your contexts ?
All I know is that in Tomcat we put them into C:\Tomcat\common\lib but you should ask someone that knows JBoss. I am going to bed now. Good night. rrz
ASKER
thanks rzz ..
>C:\JBoss-2.4.4_Tomcat-4.0 .1\jboss\l ib\ext folder.
yes .. this is our classpath.
Gd nite ...
>C:\JBoss-2.4.4_Tomcat-4.0
yes .. this is our classpath.
Gd nite ...
Sorry my mistake. For Tomcat 4 you must use JSTL 1.0 .
http://jakarta.apache.org/site/downloads/downloads_taglibs-standard-1.0.cgi
and use
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
http://jakarta.apache.org/site/downloads/downloads_taglibs-standard-1.0.cgi
and use
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
ASKER
hi there,
Already downloaded the JSTL 1.0 and copy them to the classpath. But, I stil got the error ...
" org.apache.jasper.JasperEx ception: This absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application "
please advise.
Already downloaded the JSTL 1.0 and copy them to the classpath. But, I stil got the error ...
" org.apache.jasper.JasperEx
please advise.
I am sorry again. I have been using version so long I forgot how to install 1.0 I see
http://www.developer.com/java/ejb/article.php/1447551
that you were right to install tlds and modify your web.xml. If that doesn't work then we will have to use HttpURLConnection.
http://www.developer.com/java/ejb/article.php/1447551
that you were right to install tlds and modify your web.xml. If that doesn't work then we will have to use HttpURLConnection.
ASKER
hi experts,
I have installed 1.0 successfully. However, I failed to include the following attribute crossContext="true" in my application's Tomcat Context element. I am not sure where should I include. So i got this error :
javax.servlet.jsp.JspTagEx ception: Unable to get RequestDispatcher for Context: "/importExport" and URL: "/import/test.jsp". Verify values and/or enable cross context access.
JBOSS version: JBoss-2.4.4
TOMCAT version : 4.0.1
please advise.
Thanks.
I have installed 1.0 successfully. However, I failed to include the following attribute crossContext="true" in my application's Tomcat Context element. I am not sure where should I include. So i got this error :
javax.servlet.jsp.JspTagEx
JBOSS version: JBoss-2.4.4
TOMCAT version : 4.0.1
please advise.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi rzz,
thanks... the problem is solved.
but, i stil have some problems e.g. the imported page css is not connected to its own context and caused the page not display properly. -_-''
Thanks again.
thanks... the problem is solved.
but, i stil have some problems e.g. the imported page css is not connected to its own context and caused the page not display properly. -_-''
Thanks again.