Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Injecting css tag in the response  RSS feed

 
Owais Zahid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to inject a css tag in the servlet's http response ?
 
Tim Moores
Saloon Keeper
Posts: 3882
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "inject"? The response body can be anything you want it to be. Any CSS would usually be part of the JSP (or whichever templating technology you're using), or be in a separate CSS file.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you should not be generating HTML response directly in the servlet, rather should hand over the responsibility to a JSP page. To your question, yes you can inject css tag in servlet response but that does not mean you should.
 
Owais Zahid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, i agree that this is not the recommended approach. I have a scenario where i need to create a css on the fly according to some preferences and wants to add it in all the html pages automatically.

@Piyush Mangal : Can you please what needs to be done in order to have this css file link added to response ?
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Piyush Mangal : Can you please what needs to be done in order to have this css file link added to response ?

Well that depends on how you are outputting the other HTML part as of now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!