Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Including CSS file in .jsp output  RSS feed

 
Josh Edwards
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help understanding how to include a css file in the outputted html file from this .jsp page.



Thanks in advance!
 
Tim Moores
Saloon Keeper
Posts: 3403
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are various ways to embed CSS in HTML. See https://www.wired.com/2010/02/Mulders_Stylesheets_Tutorial_-_Lesson_1#Adding_Styles for details.
 
Josh Edwards
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

I am fairly proficient with CSS and html however I don't understand how I can affect the output of this script above to include them?

Thanks

Josh
 
Dave Tolls
Ranch Hand
Posts: 2410
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You really shouldn't have any Java code in your JSP page.
That way you can just write HTML with JSTL tags to pull information from the request/session/whatever scopes.
 
Tim Cooke
Marshal
Posts: 3555
170
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you not simply reference your css file as you would in any HTML file?

Also, I second what Dave says about having Java code in your JSP. Currently you have very little JSP in your JSP.
 
Josh Edwards
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your comments. I really have a very limited understanding of Java and Jsp so don't really know what I am looking at. Basically I have received this from a client who needs this included within a wordpress page. The output of the above code is here: http://www.blanketmedia.com.au:8080/Cruise/hotnews.jsp and I just want change the style using CSS so that I can include it via iframe into the end product. Thanks
 
Josh Edwards
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering if there is a command to read the output and replace before printing?
 
Dave Tolls
Ranch Hand
Posts: 2410
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so they're not going to want you doing this properly, just quickly.

I can't see the page, but does Tim's solution work?

Actually, looking at that code, it seems to pull it's HTML entirely from the URL it's reading from.
That's not going to be just a case of adding a link tag.
 
Tim Cooke
Marshal
Posts: 3555
170
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume then that the content of cruising.com.au does not belong to you? Be sure to get the permission from the owners of that site to scrape the content and present it on your site.

If you simply include a 'window' to the other site using an iFrame then you cannot apply your own styling to it. However, if you take a copy of that site and then present it as your own, which appears to be what your code there does, then you can write your own css to apply style to it as you would any other HTML page. As you're 'fairly proficient with CSS and html' this should be pretty straight forward.

Remember it's important to get the cruising.com.au site owners permission to scrape its content and reproduce it on your site.
 
Tim Cooke
Marshal
Posts: 3555
170
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:That's not going to be just a case of adding a link tag.

It might be. Scraping the entire content and presenting it as your own means it's just HTML on your web page. Once you've found out the css class names for the scraped content you can apply your own css.
 
Stefan Evans
Bartender
Posts: 1831
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Basically I have received this from a client who needs this included within a wordpress page.

Not knowing much about wordpress, but can you include java code like this in a Wordpress page?

 
Josh Edwards
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys the code is actually supplied by cruising.com we have an agreement with them for this. Well i tried just adding the css call above the scraping and the browser is clever enough to put it in the right place. Thank you. As you said Dave it scrapes the entire page header and all so interesting it is placed correctly. I will need to check other browsers also. Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!