How to include external files in JSP

hi,
How to include external files like image or javascript in to jsp pages.
I am using MVC frame work. So i have to use request dispatcher. While calling the pages trough dispatcher the external files are missing from the output. Also am using tomcat as server,web.xml(deployment descriptor ) is also configured.
regards
sree

When you use the request dispatcher, the relative path for all your ressources becomes the relative path of your calling serlvet and not the JSP/servlet that you call. Make sure to use the full relative path such as:
/PATH_TO_YOUR_DIRECTORY/myRessource.ext
NOT
SOME_DIRECTORY/myRessource.ext
Jeff

Similar Messages

  • How to include HTML file in JSP using HTML elements or Javascript?

    Hi,
    I have around 15000 static html files one for each item which we display each upon invoking an item.The HTML file should be part of a JSP file.
    Please note that the name of the HTML file is determined dynamically
    Placing all the HTML files within the web application does not give us good performance so i would like to put all of them in the webserver.
    I am not able to include the file in the JSP using the jsp:include attribute if i place the HTML files in the webserver ,
    in order to do that i think should use either HTML element or javascript to include the HTML in the JSP.is there any alternative to <Jsp:include>
    Does anyone have an idea how to include the HTML file and take advan tage of webserver?
    Any ideas are appreciated

    What you need to do is simply read the HTML file from the disk and dump it out to the outputstream. It really is that simple.
    There's no reason you need to include all 15000 files in the actual WAR, you can place those files any place handy that is easy for the application to see (in another directory, or accessible from a file server if you have multiple front ends).
    Then, just write a utiility function that takes the output stream (i.e. the 'out' JSP variable), and the file name, read the file, and write it to the stream.
    If you start noticing performance issues, then you can try doing some caching, but truth is your OS should be doing that for you.
    But, truth be told that's the only practical way to do it.
    Another solution would be to use JavaScriipt and XMLHttpRequest (i.e "AJAX") to load the file at the client side, and simply replace a tag with the results.
    That's also pretty trivial to write, any web site talking about AJAX should give you hint there.
    Of course, that won't work for folks who have JavaScript turned off, or some other incompatible browser, whereas the server side solution obviously works everywhere.

  • How to include external files when building installer for a standalone executable?

    Hi,
    I was trying to build a stand alone executable from my Labview project and I was able to do it successfully.  Now I would like to include a few external .txt files in the installer. Those .txt files have parameters/constants that will be used by the program, and my program needs to load/read them when running.  For now I have to manually copy/paste them into the target machine, but I really hope the installer can do it automatically.  I see there is a "data" folder in the installer, and that's where I hope those .txt files can be added into.
    How can I do it? Can anyone give me some suggestions? Thanks!
    Rgds
    Harry
    Solved!
    Go to Solution.

    Norbert,
    I could not find "Add file" when right clicking the project. See attached image please. Under "Project" I do have a "Add to project" but there is no option for external files. I did not find "Source" location either.
    What did i do wrong? Is there any version requirement here? I have a 2010 base version. Thanks for your help.
    Rgds,
    Harry

  • How to include .js file in jsp file?

    hi,
    i have a jsp file with struts tag. right now i have all the javascript code as a separate function inside the jsp file itself. i want the javascript code to be present in a .js file and i want to refer that .js file from the jsp file with struts tags.
    <html:text property="Phone" value="" size="3" maxlength="3"
         onkeyup="return autoTab(this, 3, event);"></html:text>
    the above is the html tag which will call the function "autoTab" of the .js file. please help.
    thanks,
    Jayanth.

    You include javascript into a jsp in exactly the same way you do with html
    <script src="myJavascriptFile.js"/>
    It has nothing to do with the jsp per se, but rather the generated HTML page.

  • How to include External files

    Am Developing an application using servlet jsp and jakarta tomcat 5. Am using MVC frame work also web.xml(deployment descriptor). I could not include script files and image files in my jsp page as its not getting those file although i specified the path currectly. plz help me.
    regards
    sree

    When you use the request dispatcher, the relative path for all your ressources becomes the relative path of your calling serlvet and not the JSP/servlet that you call. Make sure to use the full relative path such as:
    /PATH_TO_YOUR_DIRECTORY/myRessource.ext
    NOT
    SOME_DIRECTORY/myRessource.ext
    Jeff

  • How to include a file in jsp!

    I need dynamic inlude a jsp file by use inlude file �B

    Use
    <%@ include file="file.jsp" %>
    which works at translation time so your file can be a jsp file or use
    <jsp:include page="relative url" flush="true" />
    which works at request time so the file can't contain JSP.

  • How to include .css file into jsp file in portal application

    Hi,
    I have included a .css file in a .jsp file using following tag :
    <link rel="<%=componentRequest.getWebResourcePath()%>/css/ts.css">.
    I have kept .css file under /dist/css folder.
    Preview of jsp file is fine but when I upload the jsp file and .css file to server, Look and feel of the screen is changing. When I paste the style code in jsp file, look and feel is fine.
    Can some body suggest me that why the look and feel is changing when I put the style code in css file and include it in jsp.
    Thanks in advance.
    Manish

    Hello
    We're using <link rel="stylesheet" type="text/css" href="http://ourserver/eclib/css/ecstandard.css">
    between <head> and </head>
    It works.
    Hope it helps.
    Regards
    Benoit

  • How to include CSS file in JSP

    Hi Experts,
    CSS file availabe in server. I need user that CSS in one of PDK application.
    Example: "/usr/sap/ED1/JC03/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/portalapps/style1.css"
    I need to include this in one of JSP file.
    Regards,
    Satya.

    You would have to place the file in the project folder of your PDK application and give a relative or absolute path to it.
    <link rel="stylesheet" type="text/css" href="path_to_your_css_file" />
    Thanks,
    GLM

  • How to include external JavaScript files

    Hello All,
    i'm wondering haow can i include externel JavaScrip files, there is an clip-example with a function in the same JSP file
    but not how to include a file?
    <body>
    <script language='JavaScript' src="menu/menu.js'></script>
    If some one has a clip i would appreciate.
    Thanks
    Gino

    <script src="resources/myscript.js"></script>
    I did this exact thing in my jsp but it did not work, nothing popped up.
    When I tried replacing it with:
    <script language="JavaScript" type="text/javascript"><![CDATA[
    function postMessage(message) {
    alert(message);
    ]]></script>
    It worked. Can someone tell me why? Can't i refer to javascript files this way?

  • How to include external style sheet

    Hi !!
    Can any one explain how to include external style sheet.

    Anil,
    Simply include the css file as I demonstrated in my last post and then reference one the css classes by name in the "styleClass" attribute of the component. So, if the css file that have included in my JSP file (as demonstrated in the prev post) contains a class like:
    .spicyPink {
    color:#FF1CAE;
    font-weight:bold;
    Then I would simply reference this class in the component as folows:
    <af:outputText value="Pretty In Pink" styleClass="spicyPink"/>
    However, you can also add styling to a component inline and accomplish the same task:
    <af:outputText value="Pretty In Pink" inlineStyle="color:#FF1CAE;
    font-weight:bold;"/>
    The thing to remember is that other than the use of styleClass and inlineStyle, referencing and including css in your JSP/JSPX pages is really no different that used in an HTML page.
    Here is reference to help you along:
    http://www.w3.org/TR/REC-CSS1#containment-in-html
    --RiC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to include .js file into validater-rules.xml

    iam doing project using struts.
    i have .js file for client side validation.how to include .js file into struts validate-rules.xml so that i can use those validation in my project.
    without writing any class.
    is there any way

    copy + paste from my book...............
    Enabling Client-Side Validations
    In addition to providing a framework for simplifying server-side form data validations, Validator provides an easy-to-use mechanism for performing client-side validations. Each validation routine defined in the validator-rules.xml file optionally specifies JavaScript code that can be run in the browser (client side) to perform the same validations that take place on the server side. When run on the client side, the validations will not allow the form to be submitted until they have all passed.
    To enable client-side validation, you have to place the HTML Tag Library's javascript tag in each JSP for which you want validation performed, as shown here:
    <html:javascript formName="logonForm"/>
    The javascript tag requires that you use the formName attribute to specify the name of a <form> definition from the validation.xml file, as shown here, for which you want validations performed:
    <form name="logonForm">
    <field property="username" depends="required">
    <arg0 key="prompt.username"/>
    </field>
    <field property="password" depends="required">
    <arg0 key="prompt.password"/>
    </field>
    </form>
    All the validations that you have specified for the <form> definition to run on the server side will be run on the client side.

  • How to include .jar files in coldfusion code 

    To Integrate our cfm code with paypal jar files we do the
    following steps with our local coldfusion server ,and to run and
    integrate the paypal Java SDK jar files, I think we need to do the
    same process on the server, can you suggest any thing to do the
    following setting for my domain on the server, without setting the
    class path in coldfusion administrator.
    The ColdFusion application server must be configured to know
    the location of the PayPal JAR
    files, and your ColdFusion Markup (CFM) pages must be
    configured with the absolute path to
    the PayPal API certificate for the PayPal API user on whose
    behalf the calls are made.
    1. Install the PayPal Java SDK “Installing the
    SDK”.
    2. Copy a subset of the Java SDK JAR files to a location
    accessible by the ColdFusion
    application server. The JAR files are in SDK_root\lib and
    their exact names are as
    follows:
    – bcmail-jdk14-128.jar
    – bcprov-jdk14-128.jar
    – paypal_base.jar
    – paypal_stubs.jar
    sax2.jar
    – xerces.jar
    – xpp3-1.1.3.4d_b4_min.jar
    – xstream.jar-1.1.3.jar
    3. With the ColdFusion Application Server Administrator, add
    the absolute path of the
    location you determined in Step 2 to the Java and JVM
    CLASSPATH environment variable.
    4. Restart the ColdFusion Application Server.
    Suggest me how to include .jar files without setting
    classpath.

    > Suggest me how to include .jar files without setting
    classpath.
    Copy them to {CF_HOME}\lib, where {CF_HOME} is, for example,
    C:\CFusionMX7. Restart Coldfusion.

  • How to call external files from java?

    How to call external files in java. For example how to call a *.pdf file to open in its default editor(say Acrobat), or a *.html file to open in the default browser or a *.txt file in a notepad etc..,
    In my program i have *.chm (Compiled Windows HTML Help) help file. how to open it in its default editor it?

    Jayarathina_Madharasan wrote:
    no one answered my questionHi what wrong did i do...basically insulted all the volunteers here who took the time to consider your question and try to offer you help. Other than that, you did nothing wrong.
    From JavaRanch :
    And even if an answer doesn't solve your problem, even if it should totally miss the point - the best thing to do to motivate others to continue trying to help you is showing respect and gratitude for the investment of time that was put into dealing with your issue.
    Edited by: Encephalopathic on Apr 14, 2008 10:01 AM

  • How to include the file name as an XML field

    Hi,
    I'm using a file adapter for process a flat file and convert it into an XML. Does anybody knows how to include the file name into an XML field.
    Ex.
    I process the file named <b>XXIMN21022007.txt</b> and I need an XML like:
    <MT_FILE>
    <field1></field1>
    <field2></field2>
    <field3></field3>
    <filename><b>XXIMN21022007.txt</b></filename>
    </MT_FILE>
    Regards
    Gonzalo

    Just go for dynamic configuration.
    Check the sender file adapter to write the filename in the header (as explained in Michal's blog) and then read that header in some mapping.
    U can use that even in simple message mappings.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm
    Your code for the filename tag would be something like:
    <i>DynamicConfiguration conf = (DynamicConfiguration) container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(
        “http://sap.com/xi/XI/System/File”,
        “FileName”);
    return conf.get(key);</i>
    Regards,
    Henrique.

  • How to include external .js file into .ear file using NetBean 5.5.1?

    is it possible to include external .js file into .ear file using NetBean 5.5.1? if not, then where should I placed the external .js file and how to write the src="xxx" element? (that is , how to write the path of "xxx"?)
    I am using JBOSS 4.2.2 GA as server
    thx!!

    Even 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?

Maybe you are looking for

  • Error in the RUN_RSVWSCPY phase

    Hello Support, We are having error in the RUN_RSVWSCPY phase (Shadow system Installation) In one of the phases RUN_RSVWSCPY , it runs a job in the source system (i.e RPD) Job Name :RSUG_COPY_SHD_VIEWS This Job is cancelling with UNCAUGHT EXCEPTION In

  • How to use an image instead of Browse Button in messageFileUpload item

    Hi, I have sessageFileUpload item in my OA Page to upload files. How can I show my custom image instead of a Browse button that is placed by default. I don't want to show the browse button instead want to use my custom image. Thanks

  • Cfif and displaying images.

    Here the issue. My company has an Events page user put events onto it. Well If the company is runing it my boss wants to show an image. The yes/ no or true /false will come from an admin form. So what would the <cfif> look like? <cfif (yes)> <img src

  • How can I efficiently resize photos and add zooms to send to Premiere Elements

    Hi I am regularly making DVDs in Premiere Elements V3 with about 200 pics from my  V5 Catalogue ,with  some zooms and then adding about a dozen edited video sequences, adding sound, transitions etc in premiere Elements. This is the normal profile of

  • CS3 / CS4 in Windows 7

    I know Windows 7 isn't released yet, but I wanted to see if anyone running Windows 7 64 bit has been able to use CS3 successfully. I will upgrade to CS4 if needed, but would like to wait for CS5 (or whatever is next) if possible. Thanks