How to include external js file in jsp page??

Hiii...i am new bie in jdeveloper....
and trying to add external js file to a jsp page...
the adress of javascript file is [ Web Content/WEB-INF/jsp/script/test.js ]
adress of jsp page is [ Web Content/WEB-INF/jsp/WelcomePage.jsp ]
so what source address of js file i have to give in jsp page.....

Hi,
In order for the jsp page to get the js file, it has to be accessible via an http request, and files in WEB-INF aren't. You'll have to put the js file in a different location or provide another way to get the file, such as via a servlet request.
This is the way to do it. I don't see a use case in that adding a JS file to WEB-IF provids any benefit as the sources could be looked up from the browser anyway. So if your intention is to secure the JS sources, this wont work.
Frank

Similar Messages

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

  • How to include a .js file into .jsp file.[.js file resides in a package]

    Hi,
    How do i include an external .js(JavaScript) file into a JSP file?My .js file is located in some package(lets say abc.jar). Below is my application structure:-
      jsp
       |
       ->MyJsp.jsp
      lib
       |
       |
    abc.jar
        |
        |
        ->com.abc.test
                     |
                     |
                     ->Test.java
                     ->abc.jsHow do i include "abc.js" file in "MyJsp.jsp" file?
    Please help.
    Thanks,
    Kiran
    Edited by: Adimulam on Jun 2, 2008 1:22 PM

    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?

  • 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 javascript file in an html

    hello
    i've an html file placed in apache/webapps/test folder this html file includes an external javascript file placed at same level
    i'm includind the file as
    <script src="file1.js"></script>but the file does not gets included
    but when the sam folder "test" is paste outside apache the html file including the external file runs properly.
    Thank You

    flounder wrote:
    cotton.m wrote:
    What's really pathetic is that this is your third cross post on this same stupid off topic topic.
    You are really a dumb f&#117;ck you know that?If they knew that they were a dumb f&#117;ck then they wouldn't be a dumb f&#117;ck!That's a logical and reasonable conclusion. Therefore I very much doubt that the OP is capable of it.
    Hmmm this is interesting. It now shows the entity escapes rather than their values when you quote.

  • Including external Javascript file in JSP- not working on Mozilla Firefox

    I have a JSP page which includes javascript file as below:
    <script type="text/javascript" src="https://siteAddress/scripts/myJsFile.js"></script>
    myJsFile.js has a method testFireFox()
    There is a link on JSP which that calls this method.
    <a href="#" onClick="testFireFox()">Some Text...</a>
    As soon as i click on the link, nothing happens and this error appears on console:
    Refrence Error: testFirefox() is not definedI tried giving the path for JS file in various ways but it did not help.
    Note: This works absolutely fine in Internet Explorer.
    I have not added Javascript to document.ready or onLoad event. It is simply been referred in <Head>
    tag any pointers pls..

    This forum is intended for user support, not for web development issues.
    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The contributors over there are more knowledgeable about web page development issues with Firefox.
    http://forums.mozillazine.org/viewforum.php?f=25
    You'll need to register and login to be able to post in that forum.

  • How to embad a movie file in jsp page.

    I want to run a movie file in my jsp page.
    please provide the code how to do this.
    thanks
    uttam

    Hi,
    so what source address of js file i have to give in jsp page.....in your case you can use below include command
    <jsp:include page="script/test.js" /> // here test.js is your .js file nameGenerally we need to place all jsp and js files under "jdevhome\jdev\myhtml\OA_HTML". In this case you can use
    <jsp:include page="test.js" /> // here test.js is your .js file nameor
    <%@include file="test.js" %>  // here test.js is your .js file nameregards,
    Anand

  • How to include a html file in jsp

    hi all
    I have a question about including a html in jsp.
    here's the sample of my jsp file:
    <%
    String filename = "helloworld.html";
    %>
    <%@ include file="helloworld.html" %>
    how will you go about doing it so that the included file depends on the variable "filename"? I've tried doing the following but I got an error:
    <%@ include file=filename %>
    Thank you very much :)

    try this:-
    <%
    String filename = "helloworld.html";
    %>
    <jsp:include page='<%= filename %>' />
    This should work.

  • How to include External .JS File in .aspx and .ascx page???

    This is my Code::
    .aspx Code:::
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calculator_Using_UserControl_And_Js.aspx.cs" Inherits="Calculator_Using_UserControl_And_Js" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
     <title></title>
      <script src="/JS/JavaScript.js" type="text/javascript"></script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div align="center"> 
            <p style="color:brown">Welcome to User Control Page</p> 
            A:<asp:TextBox ID="tbA" runat="server"></asp:TextBox>
            B:<asp:TextBox ID="tbB" runat="server"></asp:TextBox>
            <asp:Button ID="btnAdd" runat="server" Text="ADD" OnClientClick="return fnAdd()"/>
            <asp:Button ID="btnSub" runat="server" Text="SUB" OnClientClick="return fnSub()" />
        </div>
        </form>
    </body>
    </html>
    .JS code
    function fnAdd() {
        var v1 = document.getElementById(tbA).value;
        var v2 = document.getElementById(tbB).value;
        var res = parseInt(v1) + parseInt(v2);
        alert(res);
        return false;
    function fnSub() 
        var A = document.getElementById(tbA).value;
        var B = document.getElementById(tbB).value;
        var res = parseInt(A) - parseInt(B);
        alert(res);
        return false;
    I 've tried with the following methods but no use...
    <script type="text/javascript" src="<%= ResolveUrl ("~/Scripts/MyScriptFile.js") %>"></script>
    <script type="text/javascript" src="../JScript.js"></script>
    <script src="javascript.js" ></script>
    Thanks & Regards RAJENDRAN M

    You can write JS function as follows:
    function fnAdd(numberA,numberB,totalT) {
    var v1 = document.getElementById(numberA).value;
    var v2 = document.getElementById(numberB).value;
    var total = parseInt(v1) + parseInt(v2);
    document.getElementById(totalT).value = total;
    return false;
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    <script src="javascript.js"></script>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    A: <asp:TextBox ID="numberA" runat="server"></asp:TextBox><br />
    B: <asp:TextBox ID="numberB" runat="server"></asp:TextBox><br />
    T: <asp:TextBox ID="totalT" runat="server"></asp:TextBox><br />
    <asp:Button ID="btnAdd" runat="server" Text="Add" OnClientClick="return fnAdd('numberA','numberB','totalT');" />
    </div>
    </form>
    </body>
    </html>
    And you can do the same for fnSub

  • How to include the javafx program in JSP page

    I am working on a college project and i have got a problem that how will I can use the javafx program in JSP.
    plz imform me as soon as possible

    The JavaFX app can be included in JSP as an Applet.

  • How to import a jar file in JSP

    How to import a Jar file in JSP Page.
    please reply its very urgent!

    Hey I am facing a similar problem:
    I have this jar file lbswebservice.jar that I have to use for my application.
    I added it to the classpath, I copied it in my WEB-INF/lib folder, but when I try to access classes in this package, it doesnt work.
    For example the jar contains the package com.blipsystems.lbs.ws.messages.* ; that contains different classes, like the Campaign class.
    I tried to use this class (just to create an object) in different context (through jsp, or just through java test classes), but it never works, i get the error: com.blipsystems.lbs.ws.messages.Campaign cannot be resolved to a type
    I am a bit desperate here...

  • 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

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

  • How to display a pdf file in jsp

    hi,
    How to display a pdf file in jsp iam having a class which will return fileinputstream of the file object. the pdf file is in server.
    regards
    Arul

    A JSP is a combo of HTML and Java, so you can't really "display" a PDF file in a JSP.
    You can provider a href link to the PDF file in your JSP.
    You can use some utility package to read the contents of the PDF, pull certain things out of it, and display that in your JSP as html
    In a servlet you can set the content type to application/pdf and write the binary data of the PDF back to the browser. Once the browser finishes reading in the data it should open the PDF.

Maybe you are looking for

  • How can i reinstall cd/dvd drive - Satellite P100 PSPAD

    Hi I have Satellite P100 (PSPAD), and my cd/dvd drive (I dont know how or when) suddenly disappeard, it does not appear in my computer or device manager, I tried this but coul not find the lowerfilters so i delite the upperfilter and restart the comp

  • Music and your devices

    I upgraded my phone to the newest iPhone (4s) and can't get all of my music on it (or my iPad for that matter). It says that some of the musice is already on 5 devices. Seeing that this is my 3rd iPhone, my music has been on the 1st two, my computer

  • Better reports than microsoft access?

    Hey guys, I'm creating a system that combines java with Microsoft Access through JDBC. I'm looking to generate reports based on the information saved to the database but the reports in Access are not very nice :( Any advice on a tool that I could use

  • I have a iPhone 4 on ios 7and it wont connect to iTunes on my pc

    i had gotten my i phone recently when ios 7 came out, so i got ios 7 on my phone right away becuase i think it was cool. then i remembered about all my music i imported from my cd's on my iTunes on my pc. so i tried to connect like i do with my iPad

  • How to ensure Firefox stays updated in Linux Mint 17 - Qiana

    I happen to have dual OS, Windows OS 7 & Linux Mint 17 (Qiana). I love Linux Mint more than Windows 7. If only I could move away completely from Windows I would be the happiest person on the face of the earth. But unfortunately we're not there yet. e