JSTL c:import

I am trying to emulate the c:import (jsp:include) tag in my own tag library, I use URLConnection but this grabs the html content inline while I want the content included dynamically, does anyone another way of doing this? Thanks!
IP

I have a page.jsp that includes 3 other jsps, a.jsp, b.jsp, and c.jsp. I could easily use c:import or jsp:include to do this, but I need to do these includes in my own taglibary, such as
<%@ taglib uri="/WEB-INF/lib/myTagsLib.tld" prefix="page" %>
<table>
<tr>
     <page:PAGE_A />     
</tr>
<tr>
     <page:PAGE_B/>     
</tr>
<tr>
     <page:PAGE_C/>     
</tr>
</table>
Where PAGE_A, PAGE_B, and PAGE_C tags should import content from a.jsp, b.jsp and c.jsp respectively so that the content from these pages are included at request time (like jsp:include/c:import), I just don't know how to do this, or where to start.
Thanks!
IP

Similar Messages

  • Getting img tags to work in sub page using jstl core import tag

    Am trying to bring disparate system page reports together under one web app. This means using the jstl core import tag (I dont want to redirect as I want to hide the urls, this web app provides better security than those it calls).
    Use of the import tag works to a degree but any resources (ie. img tags) don't load.
    Have created a much simplified example that demonstrates..
    So heres the jsp...
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <h3>Delivery Performance Report</h3>
    <c:url value="http://localhost/mycontext/subpage.html" var="myUrl"/>
    <c:import url="${myUrl}" />and a simple sub page (note plain html, no jsp, this mimics my project as the other systems are hidden source, non jsp)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD>
    <TITLE>sub page</TITLE>
    </HEAD>
    <BODY>
         This is the sub page<br>
         <img src="images/banner_image.jpg" />
    </BODY>
    </HTML>While I dont get any errors what I do get is ..
    Delivery Performance Report
    This is the sub page
    ...but image fails to load.
    If I redirect instead of import it works, but as I said I need to hide the url from the user as security is an issue.
    Any help appreciated, really pulling my hair out with this final stage of something that will make a real difference to us!
    regards,
    G.

    Thanks for the answer but Im afraid thicko here doesnt get it.
    The img src is relative to the sub page, and I have tried it with an absolute address (ie. http://localhost/.....) with the same result.
    If I call the sub page direct (get with browser) the image tag works. Its just if the sub page is imported with the jstl core import tag.
    I've not tried a base tag. The real project always returns pages containing absolute urls... http://ourReportServer/reports?....plenty of params so dont belive relevant, please correct me if Im wrong here though.
    thanks, G.

  • Issue with JSTL ( c:import ) tags in Weblogic 9.2

    Hi,
    I'm trying to migrate a struts (1.2.9) application from Weblogic 8.1 to Weblogic 9.2. This application has JSPs with JSTL (1.0) tags.
    I have a JSP page that has multiple (around 7) c:import statements. When I launch my application, only the content from the last c:import statement is being displayed and rest of the c:import tags statements is simply ignored by Weblogic.
    I don't find any errors in the logs. When I comment out last c:import statement in this JSP then the content from the above c:import statement is being displayed. Only one (last one) c:import statement's content is being displayed in that whole page.
    This app worked just fine Weblogic 8.1.
    Any resolutions, hints, insights or workarounds on this issue is appreciated.
    Thanks in advance,
    Mani
    Edited by: mayyalas on Aug 10, 2009 6:13 PM

    Hello,
    You should not need to edit the wlp-light-web-lib.war weblogic.xml file. There are many places where other classes in wlp-light-web-lib are dynamically loading classes (using Class.forName()) from "higher-level" shared library modules (such as wlp-framework-full-web-lib), so I am certain that it works in general. There may just be an issue with how your shared library is set up, or how your webapp deployment descriptors are set up.
    So you mention that you have a shared library module containing your implementation of the AnalyticEventHandler; is this a .war file? And in the webapp you are trying to deploy this in, does your weblogic.xml explicitly include your shared library? If so, is your shared library being included before or after the standard WLP shared libraries?
    If you would like, posting your webapp's weblogic.xml may help to find the problem.
    Kevin

  • JSTL-c:import tag and c:param with portlets

    I am writing a JSP file in a portlet application to use the c:import JSTL tag to include a JSP file. However, I am trying to pass a parameter via c:param to this included file but the parameter is not being passed. The included JSP file gets "null" when trying to retrieve the value of this parameter, due to the fact that the parameter is not being passed. See code below:
    <c:import url="/jstltestportlet/jsp/html/test.jsp">
    <c:param name="month" value="October" />
    </c:import>
    Any ideas on why this is happening? Anybody running into this sort of a problem?
    I would appreciate any feedback.

    Here is my jsp #1: content.jsp (all the values are valid on this page)
    <c:import url="/org/j2eebuilder/view/Window.jsp">
    <c:param name="componentName" value="Home"/>
    <c:param name="componentStatus" value="None"/>
    <c:param name="windowAlias" value="/org/j2eebuilder/view/ViewControllerHelper.jsp"/>
    <c:param name="windowHeader" value="Home Management"/>
    </c:import>
    Here is my jsp #2: window.jsp (just showing various ways I have tried to get the value out)
    1. ${requestScope.componentName} 2. ${componentName} 3. ${param.componentName}
    4. <%=renderRequest.getAttribute("componentName")%>
    5. <%=renderRequest.getParameter("componentName")%>
    6. <%=request.getQueryString()%>
    7. <%= request.getParameter("componentName") %>
    8. <portlet:renderURL />
    9.<c:out value="${param.componentName}" />
    10.<c:out value="${componentName}" />
    and here is what is rendered:
    1.
    2.
    3.
    4. null
    5. null
    6. componentName=Home&componentStatus=None&windowAlias=%2forg%2fj2eebuilder%2fview%2fViewControllerHelper.jsp&windowHeader=Home+Management
    7. null
    8. /pluto/portal//Test Page
    9.
    10.

  • JSTL c:import tag exception on WAS 6.20

    Hi all,
    has anyone been able to use the c:import jstl 1.0 tag on WAS 6.20?
    Everytime we access it it throws the following error:
    Exception occurs while processing a request to the servlet: jsp.
    javax.servlet.jsp.JspTagException: Since tag handler class org.apache.taglibs.standard.tag.el.core.ImportTag implements BodyTag, it can't return Tag.EVAL_BODY_INCLUDE
    Most, if not all, other tags seem to work fine, just this one doesn't. The same testpage and jstl version works fine on other non-SAP J2EE engines we have tested it on.
    Best Regards,
    Kalle Pokkinen

    Hi,
    This answer is mostly for reference - see OSS 0371142 2004 "JSP Standard 1.2 versus 1.1" for details.
    Best regards,
    Todor

  • JSTL  XML import

    In my webpage, I want to seperate my content, style and my html/jstl.
    I have a JSTL page, a content page which is pure XML, and then my css file.
    What is the best way I can import my xml data info my jstl page?
    I know you can do it the folllowing way, but seems a bit long winded:
    <c:import url="/someFile.xml" var="doc"/>
    <x:parse doc="${doc}" var="parsedDoc"/>
    <x:out select="$parsedDoc/home/heading"/>
    perhaps javabeans? but how

    Instead of x:parse you can use x:transform, but you must specify an XSLT file.
    Do the transformation of XML with XSLT outside the JSP, then import XML and XSLT file with c:import for each inside the JSP.
    Then call x:transform to transform the XML with XSLT.
    I don't recommend JavaBeans for this, unless you want to translate XML to Java Objects and vice versa you can use JAXB to do that.
    Now there's XTags - but XTags is not fully released so it's not standardized yet and it's too early to use it.
    Message was edited by:
    appy77

  • JSTL c:import tag question

    HI
    I have a question about how the <c:param> tag interacts with <c:import> tag.
    <c:import> tag can be used to import from relative URL's like <c:import url="target.jsp" /> , from absolute urls like <c:import url="http://www.espn.com" /> or from another web application on the same server by specifying the context attribute like <c:import context="/myotherwebapp" url="some.jsp" />
    we can use <c:param> tag as an optional child tag for <c:import> to send request parameter to the page it is loading. For absolute url sending request parameters makes sense beacuse the import will be treated as new request and original request object will not be passed . but for relative urls and including the page in different web application on same web server does the jsp container treat it as part of same original request and does the target page have access to the original request object ? if this is true then how can you set additional request parameters on the request object? because once the request object is craeted by jsp container you can only add/remove attributes on it but you can never add parameters on it.
    Now if the jsp container always creates new request object for each of the above included pages then these pages will not have access to original request parameters entered by the user. Is that not a limitation.
    I am a little bit confused . hopefully somebody can help me out.
    thanks

    the c:param tag are added to the url and are not set as request parameter.
    <c:import url="target.jsp">
       <c:param var="test" value="val">
    </c:import>then is will do an import like
    <c:import url="target.jsp?test=val"/>

  • Standard.jar and jstl.jar directory

    First off I probably should apologize in advance because my problem might be an eclipse config issue.
    I created a simple servlet and I tried to include a jstl library import javax.servlet.jsp.jstl.sql.Result;. It compiled cleanly but, when I ran the application (through a browser accessing tomcat through eclipse) I was getting this error...
    The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
    I eventually found out what was wrong but I don't understand why it was wrong and that's my question. Originally I had jstl.jar and standard.jar in the projectHome/lib directory. When I moved those 2 files to the projectHome]/WEB-INF/lib directory, however, things ran correctly. Is this a setting somewhere within my tomcat config on eclipse perhaps? Or can someone point me in the right direction about this issue in general?
    Thanks in advance!

    Tomcat and Eclipse have different ideas of classpath.
    In Eclipse you set the classpath as part of the project properties: Java Build Path.
    Tomcat uses:
    - web-inf/classes directory
    - jar files in web-inf/lib
    - jar files in /shared/lib
    - jar files in /common/lib
    So in order to run on Tomcat, they need to be in the web-inf/lib directory.
    Cheers,
    evnafets

  • Does c_rt:import act like include directive or tag

    The include directive <%@ include ... will not recompile when the included file changes. The tag <jsp:inlcude will always re-fetch the included file so new content is picked up immediately.
    How do c:import and c_rt:import behave?
    Can someone point me to a good description of the difference between c and c_rt libraries. The short one or two sentence descriptions I've seen don't really say much.
    Thanks,
    -- Frank

    How do c:import and c_rt:import behave?The JSTL <c:import> tag acts like the <jsp:include> tag - it is evaluated at page runtime.
    It uses either a RequestDispatcher.forward (for local resources on the same application server) or the java.net classes to open a URL connection for remote resources.
    Can someone point me to a good description of the difference
    between c and c_rt libraries. The short one or two sentence
    descriptions I've seen don't really say much.The "c_rt" library is only included for historical reasons. If you are using JSTL and EL expressions, you should not be using the "c_rt" library.
    There is only one functional difference between the two, and it only applies to JSP1.2 containers (eg Tomcat 4).
    The "c" tags work only with el expressions: ${expr},
    The "c_rt" tags work only on standard runtime expressions ie <%= expr %>
    In a JSP2.0 containers (eg Tomcat 5), el expressions ARE runtime expressions, and you can use ${expr} or <%= expr %> interchangably with the JSTL1.1 "c" taglib.
    You should only be using the c_rt library if
    - you have a JSP1.2 container
    - you want to use <%= expr %> with one of the JSTL tags.
    Cheers,
    evnafets

  • Jsp maintenance problem

    Greetings...
    There are some vendors(appx. 10, which is expected to increase in future) doing branding of their websites for our application. As part of this integration we need to provide them with header & footer html assets (html, javascript, css and images). We have some options here for this integration
    1. The first option is to bundle all the header and footer htmls and the related assets (js,css,images) and send them directly. In this case if there is any small change in the contents then we have to re-distribute all the files again which would be a maintenance nightmare as the number of vendors will increase.
    2. The second option is to host those header/footer on our servers and provide them with some interface so that they can include those header and footer in their pages.
    I thoght of one option to use the jstl "c:import" option. But this is to the condition if the vendor is using the JSP 1.2 (?) or above which supports the use of jstl.
    We are using WAS 5.1, JSP 1.2, IBM HTTP Server.
    Question: What are the best options available for the following scenerios (if we would like to retain the control of the contents (headers/footers etc) so that we don't have to redistribute these files again for any change.)
    scenerio 1: The vendor is using JSP 1.2/2.0 ?
    scenerio 2: The vendor is using lower version of JSP (may be 1.1) ?
    scenerio 3: The vendor is using some other technology for presentation(may be ASP or plain htmls) ?
    The header code looks like:
    <script language="javascript" type="text/javascript" src="assets/shared/js/myscript.js" defer></script>
    <LINK rel="stylesheet" type="text/css" href="assets/shared/css/header.css">
    <TABLE cellspacing="0" cellpadding="0" border="0">
         <TBODY ...>
              <TR vAlign=top>
                   <TD>
                        <IMG src="images/header/blue.gif" border="0" width="119px" height="18px" />
                   </TD>
              </TR>
         </TBODY>
    </TABLE>
    Many Thanks in advance.

    <c:if test="${empty param.fname || empty param.lname || empty param.age}">But don't take my word for it, I don't have my tomcat up and running to test it.

  • Show another page in JSP

    I would like to show another web page from a different server in my JSP on Tomcat 6.0.20.
    My attempt outputs error message: The requested resource (/show/jsp/http:/mainsite:8500/first/third.cfm) is not available
    Here is my attempt:
    <jsp:include page="http://mainsite:8500/first/third.cfm" /> Please advise.

    <jsp:include> can not import pages from other servers. It can only handle local references.
    The JSTL <c:import> tag will do this though.

  • Setting the cookies in jsp

    Hi
    Iam trying to add the cookie into local machine.Problems is i written cookie program in cookietest.jsp then i incude this jsp into index.jsp.When iam accessing the index.jsp cookies are not setting But when iam acessing cookietest.jsp cookies are adding.why index.jsp accessing time not adding??please help me how to achive this one.
    below the code snippet
    **********************cookietest.jsp***********************
    <%@ page import="java.util.Date"%>
    <%@ page import="java.net.*"%>
    <%
         Date now = new Date();
         String timestamp = now.toString();
         Cookie cookie = new Cookie ("Venkateswarlu", "ravi");
         cookie.setMaxAge(365 * 24 * 60 * 60);
         response.addCookie(cookie);
    %>
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>
    **************************end*****************************
    ***********************index.jsp***************************
    <jsp:include page="/cookietest.jsp"/>
    Thanks for advace
    Venkatesearlu Ravi

    Actually this is requirment
    I have to add the that cookie code snippet to every
    page.SO what i did is i placed the cookie code
    snippet into footer.jsp.This footer jsp will include
    every page..Here cookie is not adding.
    Is there any solution.I also tried this with JSTL c:import, since the JSTL1.1 spec says that c:import covers many of the shortcomings of jsp:include.
    /p/cookies/include.jsp
    <%@ page import="java.util.Date"%>
    <%@ page import="java.net.*"%>
    <%
    Date now = new Date();
    String timestamp = now.toString();
    Cookie cookie = new Cookie ("Venkateswarlu", "ravi");
    cookie.setMaxAge(365 * 24 * 60 * 60);
    response.addCookie(cookie);
    %>
    /p/cookies/page1.jsp
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <c:import url="/p/cookies/include.jsp"/>
    <html>
    <head><title>Page 1</title></head>
    <body>
    <%request.getCookies();%>
    </body>
    </html>
    /p/cookies/page2.jsp
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <c:import url="/p/cookies/include.jsp"/>
    <html>
    <head><title>Page 2</title></head>
    <body>
    <%request.getCookies();%>
    </body>
    </html>
    But the result is the same as jsp:include as far as setting HTTP Headers (Cookies) is concerned.
    So the conclusion is that you can't really set HTTP headers in include files.
    Then, you can try it with Servlets instead of JSPs. But then, you'll need to call the servlet each time, before every JSP is invoked.
    I don' know how that's done. Probably through Filters
    (a wild guess)
    Message was edited by:
    appy77

  • Including  a servlet code within an html file

    I have an html file which should include the contents of a servlet. The html and
    servlet are reside on different webservers, otherwise I would have used JSP.
    I cant use JSP here. hope u will provide me a solution as soon as possible

    The best way of doing this would be to make the html page a jsp and use the jstl c:import tage.
    If it must be an html you could use the IFrame tabe:
    <html>
    <head>
    </head>
    <body>
    <IFRAME SRC="http://www.yahoo.com" WIDTH="800" HEIGHT="600" scrolling="auto" frameborder="0"></IFRAME>
    </body>
    </html>

  • Can not getReadMethod a jdk 1.5 bug?

    import junit.framework.TestCase;
    import org.apache.commons.lang.builder.ToStringBuilder;
    import org.apache.commons.lang.builder.ToStringStyle;
    import org.apache.taglibs.standard.lang.jstl.BeanInfoManager;
    import org.apache.taglibs.standard.lang.jstl.BeanInfoProperty;
    import org.apache.taglibs.standard.lang.jstl.ELException;
    import org.apache.taglibs.standard.lang.jstl.Logger;
    import java.beans.BeanInfo;
    import java.beans.Introspector;
    import java.beans.PropertyDescriptor;
    import java.io.PrintStream;
    public class BeanInfoPropertyTest extends TestCase {
    public Integer[] getPro1() {
    return null;
    public Integer[] getPro1(String n) {
    return null;
    public Integer[] getPro2() {
    return null;
    public Integer[] getPro2(int n) {
    return null;
    // public void testPro1() throws ELException {
    // BeanInfoProperty property = BeanInfoManager.getBeanInfoProperty(BeanInfoPropertyTest.class,
    // "pro1", new Logger(new PrintStream(System.out)));
    // System.out.println(ToStringBuilder.reflectionToString(property,
    // ToStringStyle.MULTI_LINE_STYLE, true));
    // assertNotNull(property.getReadMethod());
    // public void testPro2() throws ELException {
    // BeanInfoProperty property = BeanInfoManager.getBeanInfoProperty(BeanInfoPropertyTest.class,
    // "pro2", new Logger(new PrintStream(System.out)));
    // System.out.println(ToStringBuilder.reflectionToString(property,
    // ToStringStyle.MULTI_LINE_STYLE, true));
    // assertNotNull(property.getReadMethod());
    public void testC() {
         Class c=BeanInfoPropertyTest.class;
    try {
    BeanInfo tagClassInfo = Introspector.getBeanInfo(c);
    PropertyDescriptor[] pd = tagClassInfo.getPropertyDescriptors();
    for (int i = 0; i < pd.length; i++) {
    String name = pd.getName();
    System.err.println(name + " displayName = " +
    pd[i].getDisplayName());
    System.err.println(name + " propertyType = " +
    pd[i].getPropertyType());
    System.err.println(name + " readMethod = " +
    pd[i].getReadMethod());
    System.err.println(name + " writeMethod = " +
    pd[i].getWriteMethod());
    } catch (Throwable v) {
    v.printStackTrace();
    result test with jdk1.4.2_05
    class displayName = class
    class propertyType = class java.lang.Class
    class readMethod = public final native java.lang.Class java.lang.Object.getClass()
    class writeMethod = null
    name displayName = name
    name propertyType = class java.lang.String
    name readMethod = public java.lang.String junit.framework.TestCase.getName()
    name writeMethod = public void junit.framework.TestCase.setName(java.lang.String)
    pro1 displayName = pro1
    pro1 propertyType = class [Ljava.lang.Integer;
    pro1 readMethod = public java.lang.Integer[] com.alibaba.waf.tag.BeanInfoPropertyTest.getPro1()
    pro1 writeMethod = null
    pro2 displayName = pro2
    pro2 propertyType = class [Ljava.lang.Integer;
    pro2 readMethod = public java.lang.Integer[] com.alibaba.waf.tag.BeanInfoPropertyTest.getPro2()
    pro2 writeMethod = null
    result test with jdk1.5.0_6
    class displayName = class
    class propertyType = class java.lang.Class
    class readMethod = public final native java.lang.Class java.lang.Object.getClass()
    class writeMethod = null
    name displayName = name
    name propertyType = class java.lang.String
    name readMethod = public java.lang.String junit.framework.TestCase.getName()
    name writeMethod = public void junit.framework.TestCase.setName(java.lang.String)
    pro1 displayName = pro1
    pro1 propertyType = class [Ljava.lang.Integer;
    pro1 readMethod = public java.lang.Integer[] com.alibaba.waf.tag.BeanInfoPropertyTest.getPro1()
    pro1 writeMethod = null
    pro2 displayName = pro2
    pro2 propertyType = null
    pro2 readMethod = null
    pro2 writeMethod = null
    Why pro2 readMethod is null ,can anyone explain it

    i change the code ,but the result not change
    What?
    Please use code formatting when you post code. See formatting tips:
    http://forum.java.sun.com/help.jspa?sec=formatting
    Kaj

  • Problems getting title tags to stick

    I am trying to use iweb SEO Tool to add Title tags and analytics code to my website. I go through the process and the SEO tool says that changes have been saved to my idisk website. But when I go to google and google Nightmare 13 it still has the old title tag. The name of my website is:
    TheNightmare13.com
    I want the title tag to be (I think):
    Water Skier Freddy Krueger Jump Suits, Boat Propellers, Apparel
    If anyone is familiar with the SEO tool and would be willing to give some advice to a total hack I would really appreciate the help!
    Freddy

    Thanks for the answer but Im afraid thicko here doesnt get it.
    The img src is relative to the sub page, and I have tried it with an absolute address (ie. http://localhost/.....) with the same result.
    If I call the sub page direct (get with browser) the image tag works. Its just if the sub page is imported with the jstl core import tag.
    I've not tried a base tag. The real project always returns pages containing absolute urls... http://ourReportServer/reports?....plenty of params so dont belive relevant, please correct me if Im wrong here though.
    thanks, G.

Maybe you are looking for

  • Delete Spools created by one background job

    Hi , I have a background job which runs every now and then and it creates spools. My requirement is to delete all spools created by this one job only in regular intervals via another program. Regards, Arun.

  • All of a sudden, I can't load Microsoft Word,

    The error message says that i need to check if Word works with this version of Mac OS X ... but Excel and PP ok and Word was fine yesterday?! I just noticed that the W icon on my bar was missing ... haven't had any problems with this before......Any

  • Logout failure by AuthContext

    Hi All, I have setup a J2EE agent and IdServer successfully. I would like to write a logout jsp/servlet at agent side server. I try to use AuthContext where logout method is offered. Here is the code: AuthContext lc = new AuthContext(token); lc.logou

  • Error: distiller error upon start-up

    I am running the CC suite on a PC-Windows 7, 64bit and get error upon error which are slowing down and crashing my system: Here is the error I get upon start up of my computer: Any guidance would be much appreciated.

  • Plain Http Sender adapter - user details

    Hi experts, I am working with plain HTTP Adapters, a Java client is sending a HTTP request to XI server......the following url is used http://server:post//sap/xi/adapter_plain?namespace=<namespace>&interface=<Interface>................... &sap-user=<