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

Similar Messages

  • Need a File Parameter with Browse Functionality in ABAP

    Hi
    I Need a File Parameter with Browse Functionality in ABAP.
    Can anyone help me with logic.
    Regards,
    Sree

    Check below code:
    PARAMETERS: p_file TYPE localfile.
    DATA: l_path TYPE string,
          l_fpath TYPE string,
          l_fname TYPE string.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL METHOD cl_gui_frontend_services=>file_save_dialog
        EXPORTING
          window_title         = 'Save to...'
          default_extension    = '.txt'
          initial_directory    = 'C:\'
        CHANGING
          filename             = l_fname
          path                 = l_path
          fullpath             = l_fpath
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          not_supported_by_gui = 3
          OTHERS               = 4.
      IF sy-subrc EQ 0.
        MOVE l_fpath TO p_file.
      ENDIF.

  • Dynamic File Name with PayloadSwapBean

    I’ve  created an abap proxy with a small schema containing PO and PO_Line with an attachment that is a zipped PDF file (.zip).
    I have configured a File adapter with the payloadswapbean to place the attached .zip file in an FTP folder.  Now I need to dynamically name the .zip file using the proxy payload values.
    <PONUM>_ <POLine>.zip
    Variable Substitution takes place after the payload has been swapped so I am not able to use that.  How can I take my proxy XML payload and dynamically create the file name?  I have tried DynamicConfigurationBean but it seems to come back null when trying to read the XI FileName:
    Write http://sap.com/xi/XI/System/XI FileName I have flagged the Adapter Specific Message Attributes for FileName.
    What options do I have?

    Hi George,
    You can use Dynamic Configuration UDF code to set ASMA FileName parameter for FTP in message mapping program. Search SDN for UDF code
    Use the below UDF between source proxy field having filename and target top most node
    try{
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey KEY_FILENAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    conf.put(KEY_FILENAME, var1); //var1 from proxy payload field
    catch(Exception e){//Do some action if required}
    return "1";
    Regards,
    Praveen Gujjeti

  • Dynamic file naming with File/FTP adapter

    Hi all,
    I have a requirement for writing files with names of the files based on a customer ID.... a dynamic name based on a value retrieved from the customer DB.
    I have already tried using the dynamic file naming suggestion in the bpel dev guide, it does not work. I followed the instructions, the process fails to compile and throws "part" and "undefined variables" errors etc.
    Has anyone succesfully used file/ftp adapter to write files with dynamic file names (using a varibale), not %SEQ% or %datetime% formats?
    Thanks,
    Hasan

    You can create a header variable that will allow you to set the outbound file name inside the process. This variable is a message type. From the type chooser select:
    Message Types
    Partner Links
    Outbound Partner Link
    Outbound wsdl
    Message Types
    Imported WSDL
    fileAdapterOutboundHeader.wsdl
    OutboundHeader_msg
    This variable will have a part filename.
    Set this part to whatever you wish your file to be named.
    Select the invoke to your outbound file/ftp partnerlink. Move to the adapters tab and select the header variable you created as the Input Header Variable.

  • Using a dynamic file path with the import command

    In one of the BI Publisher blog entries it was mentioned that the curly braces tell the parser that it needs to evaluate this value first before executing the import statement. The example provided was using the built-in parameter CURRENT_SERVER_URL, but it also mentioned that this could be done with any parameter.
    I am trying to import a subtemplate using a parameter that will hold the relative path. I am using the following import command in my report template:
    <?import:file:///{$P_SERVERPATH}/Report Path/Subtemplate.rtf?>
    as well as the following declaration statement:
    <?param@begin:P_SERVERPATH?>
    It appears that the P_SERVERPATH parameter is not being evaluated before the import statement. Am I missing anything?
    Any help is greatly appreciated, we are a little over a week from migrating to a new environment and I need to nail down a solution ASAP.
    Thanks,
    John

    I believe that you cannot have a dynamic path in the import statement as it is not allowed by xsl.

  • IDOC to multiple file with dynamic file names with same content

    Hi,
    My scenario is from IDOC to file.
    The number of files which i need to create is dynamic, which depends on the number of plants.
    I have a Z-table where i will maintin list of all plants ( non SAP plant names).
    I need to fetch the data from this z-table and depending on the nunber of plants i need to create the file for each plant and fiel name should contain plant name in it. EX: abc_<plant>_datatype.txt
    I want to use only receiver one CC, and files should be created in the same directory.
    Can we do this without BPM?

    Hi,
    You can use the Mapping lookup concept to fetch the plant names from Z-tables and then you can use the variable substitution technique to resolve your purpose.
    Here you need to create multiple interfaces ie.e per plant to create multiple files. You can use common Communication channel for all.
    Mapping Lookup
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/406642ea59c753e10000000a1550b0/frameset.htm
    Mapping Lookups - RFC API
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1b439
    /people/bhavesh.kantilal/blog/2006/11/20/webservice-calls-from-a-user-defined-function
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/406642ea59c753e10000000a1550b0/frameset.htm
    Variable Substitution
    An interesting usage of Variable Substitution in XI
    /people/sameer.shadab/blog/2005/09/23/an-interesting-usage-of-variable-substitution-in-xi
    SP12 -Variable Substitution option
    Receiver File Adapter:Variable substitution :FATAL  ERROR
    Thanks
    Swarup

  • Dynamic file path with Synchonous File Read

    Hello,
    I have a scenario where there are multiple files in multiple directories that I need to read in using a synchonous file read. The directory paths are all different, but the files are all .txt files.
    1. How can I filter (i.e. *.txt) the files using a synchronous file read. It doesn't give me that option in the wizard.
    2. I already have the directory paths, but I need to assign that path string to the file adapter call out. The wizard states that I have to specify the path. Can this be done using an assign or something like that? Inbound Header? And if so how?
    Any help is greatly appreciated.

    Hi,
    1 - if not possible....you cannot set filter for synchronous read.
    2 - you can create outbound header for file adapters, change the outbound header xsd to include one more element "directory".
    close bpel project re-open it and you can then assign it runtime. That should work. I am quite positve about this.
    Dipal

  • How to handle Dynamic File Name

    Hello All,
    I have a  requirement, I have to download a file from application server to my ABAP program which will be executed in the background. The problem is the file name is a dynamic file name with timestamp on it. So how do I read the file from the application server. I know there are certain function modules but I don't think so that they can work in background.
    So If anyone has worked on it before your reply would be helpful.
    Thanks and Regards,
    Sushil

    Hi,
    Use this funcation module this will return you the list of files in a directory...
    It will work even in back group processing also..
    SUBST_GET_FILE_LIST
    or if it is unix environ ment.
    data: begin of t_tabl occurs 0,
    line(132),
    end of t_tabl,
    data: lc_command(100) type c.
    Get all the file name falling under specified directory...
    lc_command(3) = 'ls '.
    lc_command+3(45) = p_dir. " Directory of file path
    call 'SYSTEM' id 'COMMAND' field lc_command
    id 'TAB' field t_tabl-sys.
    Check any files exits in the directory.......................
    if t_tabl[] is initial.
    message e006 with 'No files exist in the specified directory ' p_dir.
    endif.
    here you will have all the file names in t_tab1 you can sort by name and will get the latest file in order..
    Thanks
    Mahesh
    Message was edited by:
            I Can Solve It

  • Include directive with dynamic attribute file

    Hello, currently I'm wrestling with the following problem. I want to include a certain file in a JSP and I'm receiving the filename to be included from the request as a parameter.
    This is my code so far.
    <%-- Include dynamical path settings --%>
    <% java.lang.String envJsp=request.getParameter("envJsp");%>
    <%@ include file="<%=envJsp%>" %>
    <%-- End Include dynamical path settings --%>
    This results in the following error:
    org.apache.jasper.JasperException: Bad file argument to include
         java.lang.Throwable(java.lang.String)
         java.lang.Exception(java.lang.String)
         javax.servlet.ServletException(java.lang.String)
         org.apache.jasper.JasperException(java.lang.String)
         void org.apache.jasper.compiler.JspParseEventListener.handleDirective(java.lang.String, org.apache.jasper.compiler.Mark, org.apache.jasper.compiler.Mark, java.util.Hashtable)
         void org.apache.jasper.compiler.DelegatingListener.handleDirective(java.lang.String, org.apache.jasper.compiler.Mark, org.apache.jasper.compiler.Mark, java.util.Hashtable)
         boolean org.apache.jasper.compiler.Parser$Directive.accept(org.apache.jasper.compiler.ParseEventListener, org.apache.jasper.compiler.JspReader, org.apache.jasper.compiler.Parser)
         void org.apache.jasper.compiler.Parser.parse(java.lang.String, java.lang.Class [])
         void org.apache.jasper.compiler.Parser.parse(java.lang.String)
         void org.apache.jasper.compiler.Parser.parse()
         boolean org.apache.jasper.compiler.Compiler.compile()
    Has anyone experience with this, or isn't it possible at all perhaps???
    All suggestions are more than welcome.
    Greetings, Johan

    try with requestDispatcher, e.g.
    RequestDispatcher requestDispatcher = request().getRequestDispatcher( request.getParameter("envJsp" );
    requestDispatcher.include(request,response);

  • Assigning file dynamically in Include directive?

    Is it possible to dynamically assign the file in Include directive?
    If posibble how? The code below does not work.
    <%
         String page_name = request.getParameter("num_id");
         if(page_name == null) page_name = "/body/that.html";
         if(page_name == "1") page_name = "/body/that.html";
         if(page_name == "4") page_name = "/body/that.html";
         if(page_name == "5") page_name = "/body/comment.html";
    %>
    <jsp:include page = "<%=page_name%>" />
    If not any alternative on doing this?
    More power!!!

    There's always this...... and you know, of course, that you do'nt compare strings with ==, right?
    <%
    String page_name = request.getParameter("num_id");
    if(page_name == null) {
    %>
    <jsp:include page = "/body/that.html" />
    <%
    } else if(page_name.equals("1")) {
    %>
    <jsp:include page = "/body/that.html" />
    <%
    } else if(page_name.equals("4")) {
    %>
    <jsp:include page = "/body/that.html"" />
    <%
    } else if(page_name.equals("5")) {
    %>
    <jsp:include page = "/body/comment.html" />
    <%
    %>

  • How to include a dynamic file

    Hi,
    The following syntax does not work:
    <%@ include file="htmls/mydocs/<%=dynamicFileName%>.htm" %>
    could you tell me how to include a dynamic file?
    thanks,
    peterzhu

    The include directive <%@ include ... does not work with dynamic file names, because it is evaluated at compile time.
    You have to use the include standard action <jsp:include page=... This is executed during runtime, and hence a dynamic file name can be used.

  • Include directive to include a JSP file from a JAR file

    I have an Eclipse project in which I have placed a JSP file in the package structure with the rest of my code. This is in fact only a code snippet page, not a full blown JSP file.
    I have a second project that is a Dynamic Web Project in Eclipse that incorporates the first project as a JAR in the /WEB-INF/lib directory.
    In this project I have a JSP file and I want to include the JSP file embedded in that JAR file.
    How do I do that?
    I'm thinking the only real solution is to rewrite the snippet portion as a custom tag.

    The JSP fragment page in question is actually a HTML form page. It is a form to be used specifically by a particular servlet. That is why they are "bundled" together in the same project, in the same package structure.
    I have multiple web applications that I want to include that form/servlet, so it gets added to these projects in the /WEB-INF/lib folder as a JAR library. But I don't want to recreate the form over and over again for each application. It would be nice if I could write a JSP page that wraps the fragment using an include directive to bring that fragment into the new page.
    So to do that with any other fragment I would write:
    <%@ include file="/WEB-INF/jsp/SOME_FORM.jsp" %>
    which works great if my fragment page is in the /WEB-INF/jsp subfolder. But if I want to access the JSP fragment as it is bundled in a JAR file, this:
    <%@ include file="/WEB-INF/lib/FORM.jar/SOME_FORM.jsp" %>
    doesn't work so good. It's just all wrong.
    I was wondering how I could just write one include statement to get what I need. There are work-arounds galore, but I thought if I could get this working it would be the simplest solution overall.

  • 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.

  • Problems with symlinks and include directives

    Any files that are included with an include directive from a file that is
              contained in a directory that is reached via a soft link do not work
              (resource not found error) if the link begins with "../".
              directory structure is like this:
              docroot/protected/symlinked_dir/subdir1a/subdir2a
              docroot/protected/symlinked_dir/subdir1b/subdir2b
              if a file in subdir2a tries to include a file in subdir2b then the resource
              is not found.
              however if I copy the symlinked directory over then it works.
              to avoid touching the symlink during the include I changed the structure to:
              docroot/protected/symlinked_dir/dummydir/subdir1a/subdir2a
              docroot/protected/symlinked_dir/dummydir/subdir1b/subdir2b
              The same problem remained. However includes in the same directory and in
              child directories work just fine.
              Is this a known bug in Weblogic or a misconfiguration of the treatment of
              symlinks?
              Thanks,
              Chris Eppstein
              

    Hi, Thanks for looking at the code.
    By messing up I mean the CSS seems to break down a bit.  The navigation moves down, the sidebar moves down and across to the right and the whole page moves across to the right side of the browser and the log in form on the top of the page breaks up and there are gaps on the page where they shouldn't be.
    It only does it in Explorer.
    Thanks again for you help.
    Ben.

  • Hi ,How can I get a list of all laptops or users with folder direction enabled or offline files enabled, be it sccm or poerwshell . i have struggled for a week.

    Hi ,how can I get a list of all laptops or users with folder direction enabled or offline files enabled, be it sccm
    or poerwshell . i have struggled for a week
    tchocr

    Hi,
    There is no such PowerShell command can achiev this. Maybe you can use a script to get the user name with folder redirection enabled. However, I am not familiar with writing script, and it would be better for you to ask in script forum below for professional
    assistance:
    http://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG&filter=alltypes&sort=lastpostdesc
    Best Regards,
    Mandy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

Maybe you are looking for

  • Error message when printing, what can I do?

    I keep getting error messages when I try to print a PDF.  This is very frustrating!  I have been trying to print tax returns from online and cant do it from this computer, which had the newer ADOBE DC.  I have tried deleting and reinstalling.

  • Macbook doesn't register TV

    Hi, I am trying to connect my mid-2010 Macbook Pro (running version 10.9.4 of OS X) to a brand new Magnavox TV. I am using an HDMI cord and a mini DisplayPort, both of which have worked in the past. When the TV is off, my computer recognizes the exte

  • Crash in OCR--any suggestions for work-around?

    There is a book from Google Books that I want to read on my computer. It's in the public domain, and I downloaded it here. I have OCR'd it using "Searchable Image Exact" in some version of Acrobat (don't remember) so I can do searches in it. But all

  • How to Call SAP ECC transactions into CRM IC Webclient Profile Screen

    Dear all, We are implementing IC Webclient application for our Clientu2019s call center operations. All sales related activities are being created in back end SAP ECC system like, starting from Quotation to Sales Order, Deliveries and Billing. Client

  • Inheriting from an abstract class

    Hi all, I'm using a certain graphics package and I need to modify a functionality of one of its classes called, say, PlainAxis. For this purpose I define a class MyAxis that derives from the class Axis which is the base class for PlainAxis as well. T