• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding Styles to .jsp containing Java  RSS feed

 
Isaac Ferguson
Ranch Hand
Posts: 1054
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am retrieving some data from a Servlet and showing it in a JSP.


Can I add CSS Style into the Java part?

Regards, Isaac
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the CSS goes into a separate file which you import into the JSP, just like you would with HTML. And that Java code belongs in a separate class. There should NEVER be Java code in a JSP.

I suggest you read this to learn about creating a JSP.
 
Isaac Ferguson
Ranch Hand
Posts: 1054
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I know, I meant if is possible to use the external css I already have it in place and I use it in the other JSP which dont get java code. The java code will be removed it is for testing purposes.

 
Dave Tolls
Ranch Hand
Posts: 2504
27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not the "Java part" that accesses the CSS.
It's the browser that reads the HTML it receives and then interprets the CSS in the tags.

Once you understand that then you know the answer to your question.
 
Isaac Ferguson
Ranch Hand
Posts: 1054
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really thing I am not expressing myself well, I meant intercalating the HTML and the Java to show the data. It is already done.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the article linked earlier? If you understood it, you know that by the time the response gets to the browser, it's just the HTML page generated by the JSP. So the fact that there is Java code in the JSP (shudders, even for testing) is completely irrelevant.

All that matters is the HTML page that is delivered to the browser. Whatever happened on the server to generate it is completely invisible to the browser and totally moot.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!