Including a *.js file in JSP

Is this the correct way to do it?
<script LANGUAGE="JavaScript" SRC="./includes/calendar.js"></script>

Hi
Follow Following Steps
1) Create scripts.js File, Add following content in this file
function popupaddpackage(urlToOpen) {
var window_width = screen.availWidth/5;
var window_height = screen.availHeight/5;
var window_left = (screen.availWidth/2)-(window_width/2);
var window_top = (screen.availHeight/2)-(window_height/2);
var winParms = "fullscreen=no"+",location=no"+",menubar=no"+",titlebar=no"+",toolbar=no"+",Status=no" + ",resizable=no" + ",height="+window_height+",width="+window_width + ",left="+window_left+",top="+window_top;
var newwindow = window.open(urlToOpen,'_blank',winParms);
newwindow.focus()
2) Create test.jsp file, Add following content in this file
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Simple jsp page</title></head>
<body>Place your content here in test.jsp</body>
</html>
3) Create index.jsp file, Add following content in this file
<HTML>
<script LANGUAGE="JavaScript" SRC="scripts.js"></script>
<BODY>
<html:form action="/actions/showSample">
<TABLE ALIGN="CENTER" CELLPADDING=0 CELLSPACING=0>
<TR>
<TD><html:submit onclick="popupaddpackage('test.jsp')" value="Add Package" style="height:23;width:100"/></TD>
</TABLE>
</html:form>
</BODY></HTML>
Thanks
aMiT Pandya
[email protected]

Similar Messages

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

  • What is the best way to include an xml file in JSP?

    I have a jsp page that I need to include an xml file. The xml file
              uses an xsl to render the file. What is the best way to include the
              xml file and still maintain the structure of the style sheet?
              Thanks
              Jennifer
              

              The best way is using the tag lib. If you cannot, but you can use JAXP, you can
              try
              javax.xml.transform.Transformer.transform(Source xmlSource,
              Result outputTarget)
              throws TransformerException
              You construct the transformer with you xsl, use you xml file or DOM to form xmlSource,
              and use JSPWriter "out" to form outputTarget (StreamResult). But if your JSP page
              generates the xml itself, tag lib is the only way.
              [email protected] (Jennifer) wrote:
              >[email protected] (Jennifer) wrote in message news:<[email protected]>...
              >> I have a jsp page that I need to include an xml file. The xml file
              >> uses an xsl to render the file. What is the best way to include the
              >> xml file and still maintain the structure of the style sheet?
              >>
              >> Thanks
              >>
              >> Jennifer
              >
              >Or is there a way to parse the xml file with the jsp page to display
              >the information. I cannot use the Java Standard Tag Libraries as the
              >version of iplanet we are running does not support the JSTL
              >
              >Thanks
              >
              >Jennifer
              

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

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

  • Including  HTML text files in  JSP where filename is variable

    Hi
    Myself new to JSP codings please do let me know via code how can thi s be done .
    i have to call a HELP JSP for the page user is navigating
    Help.jsp comes in popup. I have included header file in it HElp
    _header.jsp
    in help_body.jsp an HTML text file will be included but problem is this
    file will be decided at runtime.
    could you let me know how to pass variable file names in include .
    for the moment i will use if else
    After that help file location has to be fetched from session.

    Hi
    Myself new to JSP codings please do let me know via code how can thi s be done .
    i have to call a HELP JSP for the page user is navigating
    Help.jsp comes in popup. I have included header file in it HElp
    _header.jsp
    in help_body.jsp an HTML text file will be included but problem is this
    file will be decided at runtime.
    could you let me know how to pass variable file names in include .
    for the moment i will use if else
    After that help file location has to be fetched from session.

  • 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

  • Catch included resource or file not found error

              Hi,
              is there a way to catch the error if an included jsp is not found. (BEA 8.1 SP1)
              <Error> <HTTP> <BEA-101214> <Included resource or file "xxx.jsp" not found from
              requested resource "yyy.jsp".>
              Problem: If a jsp is not found, I want to include a default page.
              Regards
              Tobias Voigt
              

    has anyone got the solution I am getting the same error.
              mine is weblogic 6.1 in clustered env and when I am opening the browser and clicking on the link first time it is showing me no content in the pop up browser and I am getting the same error on the server as you people have got. help will be appreciated a lot as I am facing this in production env

  • How to include a .class file in a jsp page

    hi everyone,
    i know the syntax as:
    <%@ include file = "filename.class" %>
    then at run time the server could not find the class file
    if i use,
    <%@ page import = "FileName.class" %>
    then also the same problem persists
    & if i use
    <jsp:include page = "Relative address"/>
    the problem still remains as it is...
    please help me out...i am working on developing an EJB application in which client interacts with server's Stateful session bean through a jsp page...it is necessary for me to include the home interface class file in my jsp page.
    P.S. do not suggest me to include the class file in a package & then use
    <%@ page import = "packageName.ClassFileName" %>
    i
    Edited by: Ankit_JIITU on 6 Jul, 2008 1:55 AM

    Ankit_JIITU wrote:
    i have already included the remote interface class file by <%@ page import = "University.RemoteInterfaceName" %>in my jsp page ...
    if i try to make a new package called test & then include my home interface in that package...i need to import University.*to generate the class file of my home interface ; but the class file generation is not taking place as i am getting the error..
    "package University does not exist".How can i overcome this problem. The package University, which you are trying to import, must be in the classpath. If you removed it then you will have to add it back.
    i have tried my best..but tell me if there's any possible way of including a class file in the jsp page without involving a package.No, there isn't.
    If not,then pls help me to generate the class file of my home interface within a package called test.Read the New To Java Tutorial and understand how packages work.
    >
    i am assuming that u have a deep knowledge of developing EJB applications.

  • Dynamic include file in JSP page

    <span class="value">Hi
    i have index.jsp , this page can include jsp
    pages dynamically by passing the name of the page to be included to the
    index page with out .jsp , so if i want to include page "code.jsp" i
    put: .../index.jsp?page=code , this have to include code.jsp page
    i made the following code , but it did not find the file
    so can any one help plz ?
            String pg=request.getParameter("page");
            if( pg!= null && ! "".equals(pg)){
                    File f=new File(request.getParameter("page")+".jsp");
                    if(f.exists()){
                            out.print("file exist");
                            %>
                            <jsp:include page="<%=request.getParameter("page")+".jsp" %>" />
            <%
                    }else{
                            out.print("file not exist");
         

    What does the file existing or not really have to do with it?
    You can try it like this:
    String pg=request.getParameter("page");
            if( pg!= null && ! "".equals(pg)){
                    String webPath = pg + " .jsp";
                    String realPath = request.getRealPath(webPath);
                    File f=new File(realPath);
                    if(f.exists()){
                            out.print("file exist");
                            %>
                            <jsp:include page="<%= webPath %>" />
            <%
                    }else{
                            out.print("file not exist");
            }Alternatively you could try using a request dispatcher:
    RequestDispatcher rd = request.getRequestDispatcher(webPath);
    if (rd == null){
      // doesn't exist
    }

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

  • Urgent: Including a dynamically creted file in JSP

    Hi all,
    My problem structure is like this
    In my JSP page i am haiving one String which contains a source code of the other JSP. When i use out.println to print the code it works fine for all the HTML tags, but the JSP tags don't get processed. The reason behind this could be that the string is being printed after JSP translation phase. Now my requirement is the same String which contains some JSP code should work like normal JSP.
    I tried following solution, which is not working
    1.In the same JSP file i created a temparory xyz.jsp file with that String contents
    2.And i am trying to include that file using <jsp:include page="xyz.jsp/>
    3.I am using Weblogic 7.0, So in order to deploy the application i have to create .ear file and then proceed.
    4.The temperory file xyz.jsp is being creted in the domain folder of the server. which is out of the web context
    5.Now i am not able to access that temperory file, since it is not in the context.
    I am confused about the approch itself, because it involves IO and could make the application slow.
    Is there any other way to solve this problem ??
    Thanks in advance
    --Bhupendra Mahajan

    I know that this is the "New To Java Technology" forum, so my suggestion may be more than you want to tackle, but how about custom JSP tags?
    http://java.sun.com/developer/Books/javaserverpages/cservletsjsp/chapter14.pdf
    They allow their body content to be manipulated / evaluated. I don't know if they're appropriate in this case, since I haven't seen your code and don't know specifically what you're trying to evaluate, but I thought it would be worth it to suggest them.

  • How I can include js (javascript) file in a jsp page?

    Hi,
    I�ve tried to include a js (javascript) file in jsp file but it doesn�t work.
    When I try to use a js function in the browser I always receive an error. Oh, of course, I�m including the correct tag <script src= ...
    What can I do? Does the problem in the WebServer?

    I cheated and put the scripts in another '.jsp' file and had no problem...then put an include b4 the closing 'head' tag, like this:
    <jsp:include page="scrpt.jsp" flush="true" />
    I had to do it this way for debugging using JDeveloper (it doesnt seem to like '.js' files). But when the jsp is on the server I used the following line instead:
    <script language='JavaScript' src='scrpt.js'></script>
    hope this helps.

Maybe you are looking for

  • J2ME game programming

    Helo everyone, I am working in j2me game programming plz if any one know how make image as small as possible in our game program.? I am using *.png format of image which is working well in game but my game size is very big so plz help me to get out o

  • HELP - Screen informatio​ns related to FN key

    Hello guys,  First of all, I'm a noob here, so please forgive me if I'm posting this at the wrong session. I've searched the forum to check if there's any topic similar to this problem, but i didn't finded. I recently reinstalled the windows 7 on my

  • Can't install bootcamp on Macbook Pro (2007 17-Inch) disk.sys error

    Hi, I have a problem with a 2007 Macbook Pro that refuses to boot the Windows 7 Installer. When booting the disk it stays at "Starting Windows" and if I boot into Safe mode it stays stuck at "Loading: disk.sys". I made the windows partition using boo

  • Check the case in our production database and development

    at our end development : - TABLE NAME     NUM ROWS     BLOCKS     AVG ROW LEN     CACHE     SAMPLE SIZE     LAST ANALYZED CP_BAGS     4,206,402      195,932      323      N     4,206,402      07/08/2007 CP_DAILY_INV_ACTIVITY     5,549,944      95,777

  • [SOLVED]SYSLINUX - dual bot arch and gento - fail

    Hi I am experimenting with gentoo (well not just yet and i can not boot the gentoo kernel. Gentoo is on partition /dev/sda6 and doesn't have a boot flag. Partitinon /dev/sda1 has a boot flag. I don't have a separate boot partition. Gentoo kernel was