A variable in the include directive

Hello,
I'm trying to store a part of the name of the file to include in a variable like this:
<%@ include file=templatepath + "settings.jsp" %>
but it doesn't work. Can someone tell me if there is a working way to do something similar
Thanks,
Store

You can use the jsp:include tag to specify the page to include dynamically.
<jsp:include page="templatepath + "settings.jsp" flush="true"/>You can't use the include directive to dynamically specify a page since the page is included at compile time, rather than run time.

Similar Messages

  • Using the "Include" directive

    Hi,
    Does anyone know how to specify the location from where one
    action script or mxml file can include an other actionscript code?
    For example, I have a file mypanel.mxml that is in project1 and
    myshared.as in project2. I need to "include" myshared.as in
    mypanel.mxml without specifying the physical location of
    myshared.as in the filesystem, to the include directive.
    Please help in this regard.
    Thanks.

    I think you go to your project properties Flex Build Path
    area and add a path to the "Source path" tab.

  • The Include Directive (at Page Translation Time)

    Version: 5.1
              Service Pack: 6
              I am generating the following error when I attempt to manually compile a JSP
              file:
              [jspc] parsing /vobs/projects/public_html//test.jsp:
              WARNING: Failed to include file 'test.inc' in include directive of page
              /test.jsp
              I've attempted practically every permutation of full and relative path
              locations, and cannot get it to work. Weblogic's JSP documentation did not
              have much to say about this either.
              Is anyone aware of a bug in the jsp compiler that would cause such a
              problem?
              

    Really strange, I used absolute path and put it under docroot, and I didn't
              put that folder into my any of my classpaths, the wls can find it without
              any problem. I used wls5.1 and sp6, do I miss sth?
              Thanks.
              mreiche <[email protected]> wrote in message
              news:[email protected]...
              >
              > No, it's not useless to add the include directory to the classpath - due
              to a bug in WLS 5.1,
              > it looks in the classpath for include files that begin with '/'.
              >
              > He is using the absolute path. That's why WL does not find it.
              >
              > Mike.
              >
              > "Tao Zhang" <[email protected]> wrote:
              > >
              > >Anchal Jain <[email protected]> wrote in message
              > >news:[email protected]...
              > >>
              > >> I added the directory that contains the included files to the
              > >> classpath but I still get the error below.
              > >It's useless to add such directory to the classpath. Please remove it.
              > >In order to recompile it dynamically you have to set it up in
              > >weblogic.properties file.
              > >
              > >>
              > >> WARNING: Failed to include file 'authenticate.jsp' in include
              > >> directive of page /analyze.jsp
              > >>
              > >You should inlcude all these jsps under your docroot.
              > >
              > >Make sure the relative path of include directive is right. Or you can use
              > >the absolute path and try.
              > >
              > >> Do I have to compile the included files
              > >> individually and then compile the main jsp?
              > >>
              > >> Any suggestion will be greatly appreciated.
              > >>
              > >> Anchal
              > >>
              > >>
              > >> "Greg Panzer" <[email protected]> wrote:
              > >> >The Weblogic JSP compiler is looking in the classpath for the include
              > >files.
              > >> >
              > >> >When manually compiling the JSPs, put the docroot in the CLASSPATH.
              > >> >
              > >> >Greg Panzer <[email protected]> wrote in message
              > >> >news:[email protected]...
              > >> >> Version: 5.1
              > >> >> Service Pack: 6
              > >> >>
              > >> >> I am generating the following error when I attempt to manually
              compile
              > >a
              > >> >JSP
              > >> >> file:
              > >> >>
              > >> >> [jspc] parsing /vobs/projects/public_html//test.jsp:
              > >> >> WARNING: Failed to include file 'test.inc' in include directive
              of
              > >> >page
              > >> >> /test.jsp
              > >> >>
              > >> >> I've attempted practically every permutation of full and relative
              path
              > >> >> locations, and cannot get it to work. Weblogic's JSP documentation
              did
              > >> >not
              > >> >> have much to say about this either.
              > >> >>
              > >> >> Is anyone aware of a bug in the jsp compiler that would cause such a
              > >> >> problem?
              > >> >>
              > >> >>
              > >> >>
              > >> >>
              > >> >
              > >> >
              > >>
              > >
              > >
              >
              

  • Dynamic file parameter with include directive

    I would like to include the file path contained in a string variable with the include directive.
    I'm trying to do the following:
    <%
    String var_fileToInclude = "inc/topnav_" + var_sectionType + ".jsp";
    include file=var_fileToInclude;
    %>
    I get the following error:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 6 in the jsp file: /news/special_reports/climate/inc/topnav_includer.jsp
    include cannot be resolved to a type
    3: String var_fileToInclude = "inc/topnav_" + var_sectionType + ".jsp";
    4: out.println( "var_fileToInclude = " + var_fileToInclude );
    5:
    6: include file=var_fileToInclude;
    7:
    8: %>
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    Any help is greatly appreciated.
    -- Ryan Chapin

    hello,
    Are you able to print the file name. if you are able to print the file name properly then try to include the file as below
    <jsp:include page="<%=filevariablenema%>" flush="true" />
    I hope this will help. Let me know on the same.
    Thanks
    Suresh

  • What's the difference between include directive & include action tag?

    I no that the directive is used for including static content,
    while the action is also used for dynamic content.
    So the first one will include the content into the JSP only at compilation time. The second one will include the content every time you access the JSP.
    *<html>*
    *<body>*
    *<h1> Include Action test PAge</h1>*
    *<h2> Using the include directive</h2>*
    *<%@ include file="included2.html"%>*
    *<%@ include file="included2.jsp"%>*
    *<h2> Using the include action</h2>*
    *<jsp:include page="included2.html" flush="true"/>*
    *<jsp:include page="included2.jsp" flush="true"/>*
    *</body>*
    *</html>*    I tried withis code. But its giving the same result.I didn't modified the source. I modified in the included file.As I request for the JSP page I got the same result for both.
    so i just want to know that is thier any way or example by which i can see the difference between these two clearly..
    please help me out.
    thnx.

    As our almighty Google says: @include is compiletime and jsp:include is runtime.
    Install Google at your machine. It's really great. It has answers on almost all questions.

  • JSP:Include directive - can I access data?

    Hi,
    I am using the 'include' directive (either jsp:include method or <%@ include.... /> ) to include another jsp page.
    I want the included file to access variables that have been set up in the main page (the one with the include directive in it). I've tried several things, including setting up a Bean class, but nothing seems to work
    Is this possible? I really appreciate any help with this.
    Thanks.

    You cannot use <%@ include ..%> because that is resolved at translation time. <jsp:include /> is resolved dynamically and should give you what you need. In the main page, store references to the bean or other data as request attributes and then retrieve them in the included page.

  • Compiler Include Directive

    Is there an equivalent to the include directive? I don't mean the import statement, I mean the include directive such as available in many other languages that will place the contents of a file inline with the java source.
    Basically, just like the JSP include. I have a program of about 100 servlets and parts of the code is exactly the same in every servlet.
    The code is too small to create a seperate class and call it from every servlet and I'd consider it needless overhead.
    I've gotten most of the functionality by creating an interface and implementing and using final variables but I have blocks of code that I want inserted inline at different places within some methods. final is okay for variables but I need to insert lines of code, which final won't work for.
    Thanks,
    Bob

    Why not just have all the servlets be subclasses of some servlet class that includes that common code as a method?

  • Variable name in include

    Hi,
    I am trying to include the contents of one dynamically created jsp file in another. I have tried all variations of include:
    <jsp: include page = "<%=url%>" />
    <%
    RequestDispatcher rd = request.getRequestDispatcher(url);
    try { rd.include(request, response); }
    catch (Exception e) { }
    %>
    <% String url = cid+"/Quizzes/quiz1.jsp";%>
    <jsp:directive.include file="<%= url %>" />
    Nothing works. I need to access an array that is dynamically created in quiz1.jsp. Can anyone help??

    In order to access any variable from the included file you need to store this value as an attribute:
    // in the included page
    pageContext.setAttribute("myKey", myObject, pageContext.REQUEST_SCOPE);
    // in the including page
    Object obj = pageContext.findAttribute("myKey");Included pages do not compile along with including pages. They become different servlets.

  • Jsp:include directives compilation errors

    hi,
    we have lot of <%@ include file="" %> files in out jsp page. when we trying to change this to <jsp:include page="" %>. we r getting lot of comilation errors
    The file size is increasing more than 64mb.
    Can u tell how to contain them within 64mb .
    thank you.

    The stack trace isn't very indicative of whatever problem you may be having.
    However, there is a major difference between <%@ include %> and <jsp:include />. The include directive <%@ include %> slams the content of the included resource into your JSP at compilation time, it is "static". No individual evaluation of the included resource is done, it becomes a part of the JSP that included it.
    <jsp:include /> is a dynamic include--it is evaluated at run-time. The content of the included resource is accessed and written to the output stream with the JSP is accessed. If the included content is a JSP, it is compiled and accessed as a separate servlet.
    So, it looks like your included JSPs do not qualify as valid, standalone JSPs. Typically, this is because of some dependency on variables or beans declared in the including JSP.
    Good luck.
    -brian

  • JSP include directive not working with Tomcat 5.0

    Hi.
    I'm developing a small JSF webapp under Tomcat 5.0. My idea was to use the include directive to display a navigation panel on every JSP page.
    I took the code straight from the Java Web Services Tutorial; the resulting page looks like this:
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
           version="2.0">
    <jsp:directive.page contentType="text/html;charset=iso-8859-1"/>
    <%@ include file="/jsp/panelpage_header.inc" %>
         <h:outputText value="Welcome!"/>
    <%@ include file="/jsp/panelpage_footer.inc" %>
    </jsp:root>However, when I try to load the page, a compilation error occurrs:
    org.apache.jasper.JasperException: /trias/welcome2.jsp(11,2) The content of elements must consist of well-formed character data or markup.
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
    ...I checked the path to the included files, and it seems to be okay. The files themselves contain the JSF tags for the view, html-head, html-body etc. The compiler doesn't even care if the files exist or not because it aborts immediately when it reaches the first include-statement.
    Did anyone see this kind of error before?

    Ok, the solution with jsp:directive.include works,
    if header.inc and footer.inc themselves are well
    formed too. If I understood the concept right this is
    because header and footer are processed during
    request time and therefore interpreted as
    'standalone' pages.This isn't true. The include directive (<jsp:directive.include>) is run a Compile Time. The code is inserted directly into the surrounding JSP (unlike <jsp:include> which forwards the request at runtime). The finished JSP, after the include, is then processed and needs to be well-formed XML.
    >
    But: What can I do when these two files define a tag
    that should enclose my current page (for example,
    header opens a panelGrid-Tag, and footer closes it).
    For this case I thought the use of the
    @include-directive would be neccessary to combine the
    three pages during compilation. By this the resulting
    page would be well-formed although header and footer
    are not.It should be, as long as you are using <jsp:directive.include>, and the rest of the included pages are also well formed (no <% %> tags, nothing else out of place...).
    Honestly, I haven't done much work with JSP documents, so I haven't run into this problem. But I do believe everything I said is correct.
    What I would do is double check the correctness of the rest of the included pages and see if your error isn't something else.

  • 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

  • Include directive with import tags how to

    I mostly the same classes throughout many of my jsp pages. If I use the include directive to import the classes - it doesn't work. What is the proper directive / way / tag to include those tags? Sorry if I am not wording this properly. Here's an example:
    most of my classes use the following classes so I use the @import tag:
    <%@page import="web.urls.DisplayUrls"%>
    <%@page import = "web.beanObjects.display.DisplayPage"%>
    <%@page import="web.db.admin.TypesDbHandler"%>
    <%@page import="web.db.admin.CategoryDbHandler"%>
    I would like to put all of those in one file and only have one line of code so I don't have to cut & paste into every jsp page whenever there's a change:
    <%@include file="/include/imports.jsp"%>
    Unfortunately this isn't working, it's not recognizing the classes...
    Thanks!

    hi,
    since both the files are located in the same folder, why don't you try the following:
    <%@ include file="hello.jsp" %>
    hope this helps

  • Problems with include where the include is a jsp

    Hi ,
    I have a typical problem. The iplanet server doesn't interpret the code
    from a jsp which is included in another jsp. For eg.
    code for main jsp
    request.getParameter("username");
    <%@ include file="/jsp/ui/left_nav.jsp" %>
    processing code.
    Now when I start the server and the first time I load this page I get a
    dearranged page which has the code of the left_nav.jsp present in the html
    output.
    On opening this page to edit, when a small modification is made and the file
    is saved, a reload of the same page gives the proper output with all the
    jsp's interpreted.
    Thanks to one and all,
    Regards,
    Gurjit

    You definitely want to use a jsp include action, not a directive. The directive
    happens at translation time and does not process the requested page. An action
    happens at request time and treats the requested page as a new request, thus
    including the results of the invoked jsp.
    BTW, the include action is the tags that looks line <jsp:inculde
    page="included_page.jsp" flush="true"/> or something similar (parameters can
    also be specified).
    The JSP 1.1 spec has more details. See sections 2.7.5 & 2.7.6 (for the include
    directive and a quick comparison of the directive vs the action) and 2.13.4 (for
    the include action).
    Matt
    Gurjit wrote:
    Hi ,
    I have a typical problem. The iplanet server doesn't interpret the code
    from a jsp which is included in another jsp. For eg.
    code for main jsp
    request.getParameter("username");
    <%@ include file="/jsp/ui/left_nav.jsp" %>
    processing code.
    Now when I start the server and the first time I load this page I get a
    dearranged page which has the code of the left_nav.jsp present in the html
    output.
    On opening this page to edit, when a small modification is made and the file
    is saved, a reload of the same page gives the proper output with all the
    jsp's interpreted.
    Thanks to one and all,
    Regards,
    Gurjit

  • How to include servlet in JSP using Include Directive?

    Hi experts,
    am a beginner to JSP.. I want to know,
    is it possible to include a servlet in jsp using include directive? could any one explain me...

    No it is not possible.
    Include directive is like copying and pasting some text into a JSP file, and then translating/compiling it.
    So the only thing you can include with the <%@ include %> directive is a jsp fragment
    It is a static translation/compile time include and thus will always be the same
    By contrast <jsp:include> is a runtime include, and includes the result of running the imported url.
    That URL has to be a complete/standalone jsp/servlet/whatever. However as it is runtime, it can take parameters where the include directive can not.
    Does that answer your homework question?
    Cheers,
    evnafets

  • How to use the variables of Function exit in the include program

    i have a problem of using the variables of a function exit in the include program..
    If i use those variables there will be an error indicating 'Field FEBVW_IN is unknown. It is neither in one of the specified tables nor defined by a DATA statement'. Please help... Below is the code of the function exit:
    FUNCTION EXIT_SAPLIEDP_202.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     VALUE(IDOC_CONTROL_INDEX)
    *"     VALUE(IDOC_DATA_INDEX)
    *"     VALUE(FEBVW_IN) LIKE  FEBVW STRUCTURE  FEBVW
    *"     VALUE(FEBKO_IN) LIKE  FEBKO STRUCTURE  FEBKO
    *"     VALUE(FEBEP_IN) LIKE  FEBEP STRUCTURE  FEBEP
    *"     VALUE(FEBRE_IN) LIKE  FEBRE STRUCTURE  FEBRE
    *"     VALUE(FEBPI_IN) LIKE  FEBPI STRUCTURE  FEBPI
    *"  EXPORTING
    *"     VALUE(I_FIMSG) LIKE  FIMSG STRUCTURE  FIMSG
    *"     VALUE(FEBVW_OUT) LIKE  FEBVW STRUCTURE  FEBVW
    *"     VALUE(FEBKO_OUT) LIKE  FEBKO STRUCTURE  FEBKO
    *"     VALUE(FEBEP_OUT) LIKE  FEBEP STRUCTURE  FEBEP
    *"     VALUE(FEBRE_OUT) LIKE  FEBRE STRUCTURE  FEBRE
    *"     VALUE(FEBPI_OUT) LIKE  FEBPI STRUCTURE  FEBPI
    *"  TABLES
    *"      IDOC_CONTROL STRUCTURE  EDIDC
    *"      IDOC_DATA STRUCTURE  EDIDD
    *"      IDOC_AVIP STRUCTURE  AVIP OPTIONAL
    *"      IDOC_AVIR STRUCTURE  AVIR OPTIONAL
    *"      IDOC_AVIT STRUCTURE  AVIT OPTIONAL
    *"  CHANGING
    *"     REFERENCE(IDOC_AVIK) TYPE  AVIK OPTIONAL
    *"  EXCEPTIONS
    *"      PROC_ERROR
      INCLUDE ZXF08U10.
    Here is the code for the include program.
      INCLUDE ZXF08U10
    MOVE febvw_in TO febvw_out.

    Sometimes you will get this error message when checking include code in exits even though there is really no error - it happens because the include does not realise it is in the function due to the navigation index being out of date.
    Try activating the code - it may work even though the check said there were errors.
    You can also get this issue when trying to drill down on the field in the include to view its structure.
    Andrew

Maybe you are looking for

  • R12 Check Printing for Suppliers Created for Employee Payments

    Hi, We have some suppliers that are created to to pay employees. Problem we are finding is:The address printed on Check (i.e. Payee address) is coming from HRMS, and not from Payables. E.g. Say Address set at employee level is London Address, and the

  • How do i set a data usage alert

    How do I set a data usage alert?

  • Problem: Custom Flash Professional Component

    Hi, I just installed a copy of Flash Builder 4.5, and am attempting to create a custom "flash professional component" in the Design mode of an mxml project. The documentations mentioned that in order to create this component, I have to press on the '

  • Upload Entire Site

    I run a 300+ page site that I need to make changes to on a daily basis. When I upload, I send the entire site (just in case there are new images etc. lurking in there). Is this the best/only way to do this?

  • Exploring and Exploiting the Bridge Libraries

    One of the things we did when we developed the Bridge Workflow Automation Scripts, was create a set of libraries to make bridge scripting easier and more productive. The libraries are AdobeLibrary1.jsx and AdobeLibrary2.jsx. There is an AdobeLibrary3