Results 1 to 5 of 5
  1. #1
    arpbansal is offline Member
    Join Date
    Aug 2010
    Posts
    3
    Rep Power
    0

    Question Urgent: Linking js & css files with JSP

    Hi,

    I am using Eclipse ide for web development,
    And the problem is with including js & css files in JSP page…

    basically i have these files mojomagnify.js and mojomagnify.css in the project "Alpha" ,

    [IMG]C:\Documents and Settings\bansalar\Desktop\dirpath.bmp[/IMG]

    and i used this code initially,
    <script type="text/javascript" src="mojomagnify.js"></script>
    <link type="text/css" href="mojomagnify.css" rel="stylesheet" />


    By this way, js & css files are not executed. (I guess its not able to locate this files)

    So I tried to put some absolute path like this ->
    <script type="text/javascript" src="c:/images/mojomagnify.js"></script>
    <link type="text/css" href="c:/images/mojomagnify.css" rel="stylesheet" />


    Now it works when I run the application in Eclipse,
    But when I try to run it in the browser, it doesn’t work…

    Then i put the js & css files in "images" folder in the WebContent, and tried to set the context path like this,
    <script type="text/javascript" src="<%=request.getContextPath()%>/images/mojomagnify.js"></script>
    <link type="text/css" href="<%=request.getContextPath()%>/images/mojomagnify.css" rel="stylesheet" />


    But again it doesn’t work.

    Can any one guide me, how to solve this problem??

    Thanks,
    Arpit Bansal
    Last edited by arpbansal; 08-06-2010 at 07:41 PM.

  2. #2
    flyfisherman is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    Few important things

    1. do not start topic with "URGENT" because it isn't.

    2. what IS urgent here is the problem that you don't know anything about paths. For example, you tried to show us bmp file (in the name of God do not use BMP) from your disk (C:\Documents and Settings\bansalar\Desktop\dirpath.bmp)

    3. As I can see you place app files on C root ? What do you expect after 10 projects? Also what do you think about your wokspace dir ?

  3. #3
    arpbansal is offline Member
    Join Date
    Aug 2010
    Posts
    3
    Rep Power
    0

    Default

    Sry 4 that,

    workspace dir luks like this :-

    C:\Documents and Settings\bansalar\workspace\Alpha\WebContent
    -->images
    .......-->mojomagnify.js
    .......-->mojomagnify.css
    -->META-INF
    -->WEB-INF
    -->index.jsp
    -->MoZo.jsp
    -->mojomagnify.js
    -->mojomagnify.css

  4. #4
    arun9683 is offline Member
    Join Date
    Jun 2010
    Location
    Bangalore,India
    Posts
    70
    Rep Power
    0

    Default

    use following code
    Java Code:
    <script src="mages/mojomagnify.js"></script>
    <link type="text/css" href="images/mojomagnify.css" rel="stylesheet" />
    And why do you have the duplicate files?

    If the js & css files kept kept out side of the images folder then the your first try should work..
    Last edited by arun9683; 08-10-2010 at 11:14 AM.
    Arun K R,Bangalore,India
    :)

  5. #5
    arpbansal is offline Member
    Join Date
    Aug 2010
    Posts
    3
    Rep Power
    0

    Exclamation

    Dude thats the problem, its not working...
    And the code u told i tried that also, its not working...
    & the interesting thing is i tried the same thing in Netbeans IDE and it was working there, i dont know wats wrong with the Eclipse??
    If anyone knows any way, then plz do let me know...Thanks !!!

Similar Threads

  1. Linking constructors
    By willemien in forum New To Java
    Replies: 3
    Last Post: 05-05-2010, 12:31 AM
  2. Linking Jframes
    By nonabhai in forum AWT / Swing
    Replies: 2
    Last Post: 03-04-2010, 03:44 PM
  3. Linking of exe files
    By archu2friends in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-06-2008, 07:08 AM
  4. <URGENT> problem after linking .jnlp
    By bongia in forum New To Java
    Replies: 14
    Last Post: 11-18-2007, 06:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •