• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

linking css and javascript with JSP pages

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i am new to this comunity and currently i am doing a project based on MVC architechture. since i am new to JSP,i need help on connecting my external style sheet with my JSP pages..actually i converted a html page into JSP page. it is working quite well in my TOMCAT server AND MYSql back end..But the problem is, it is not showing any pictures and css effects and also i created a roll over effect using javascript..but after i converted these into JSP pages, all my design effects are lost and only text contents are displayed..should i use any concept related to taglibs and cant i use same old css and java script in my JSP pages..Please Give suggestions..THANK U IN ADVANCE..

[ January 29, 2007: Message edited by: srinivasan ramarao ]
[ January 29, 2007: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67502
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd bet my left ear that you are using page-relative addressing for your CSS and image files. Bad idea.

Search this forum for previous discussions of using server-relative URLs for external resources.
 
srinivasan ramarao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
I'd bet my left ear that you are using page-relative addressing for your CSS and image files. Bad idea.

Search this forum for previous discussions of using server-relative URLs for external resources.



so..cant i use my old way of adding css files into a web page..i mean as i used to do in html pages..i have stored all the required css,pictures and javascripts in the same folder..so which statement or tag should i use in jsp to make it possible or in what way of approach can i do it.u mentioned about server related url.. i cant get you..??
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey wether you make a html page or jsp page that wont affect your css or javascript just import/link these files in your pages or declare the scripts and styles within the page.

I mean you can either associate a page to a js file or declare your javascripts within the page.

look below -
this how you get your css file to your page
<link href="path/xyz.css" rel="stylesheet" type="text/css">
this how you get your js files that you have made on your page
<script language="javascript" src="<%=JsFilePath%>/cr/ManageHCP.js"></script>
 
srinivasan ramarao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Avneet Singh:
hey wether you make a html page or jsp page that wont affect your css or javascript just import/link these files in your pages or declare the scripts and styles within the page.

I mean you can either associate a page to a js file or declare your javascripts within the page.

look below -
this how you get your css file to your page
<link href="path/xyz.css" rel="stylesheet" type="text/css">
this how you get your js files that you have made on your page
<script language="javascript" src="<%=JsFilePath%>/cr/ManageHCP.js"></script>



thank you for your suggestion. it helped me. i got it right..
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear's point, and it's an important one, is that your pages will be more robust, if you make your links relative to the root of the webapp instead of being relative to the page location. This is especially important if you start using an MVC architecture or if you use response.forward to forward to a page in another directory.

The following example creates a link to a image that is relative to the root of the application.


Or, for pre JSP 2.0 containers:
 
srinivasan ramarao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
Bear's point, and it's an important one, is that your pages will be more robust, if you make your links relative to the root of the webapp instead of being relative to the page location. This is especially important if you start using an MVC architecture or if you use response.forward to forward to a page in another directory.

The following example creates a link to a image that is relative to the root of the application.




Or, for pre JSP 2.0 containers:




thank you Ben Souther for making me to clear my doubt...i will try the same..
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic