• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

init of servlets and jsp  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where can we provide the infomation of servlet's init() method in jsp
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't.

You shouldn't need to anyway. JSP aren't meant to hold business logic, only display logic.
If you think you need to put any computation or data manipulation code in a JSP you need to instead rethink your application design.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jeroen Wenting:
you can't.

You shouldn't need to anyway. JSP aren't meant to hold business logic, only display logic.
If you think you need to put any computation or data manipulation code in a JSP you need to instead rethink your application design.



You have got the best suggestion, Vara.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>you can't.

Why? Your jsp page may extends your own class and you can have your own
jspInit, jspDestroy

I am not discussing is it good or not, but technically it is possible and it is described in the spec.
 
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>I am not discussing is it good or not, but technically it is possible

correct, its technically possible.
You have to override _jspInit() in a <%!......%> (declarative tag).

ram.
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by vara prasad:
where can we provide the infomation of servlet's init() method in jsp



You can declare your JSP page as a servlet in your web.xml file and provide intialization parameters just like you would any other servlet. Then, in your JSP page, you can access the implicit config object (a ServletConfig instance) to access the servlet-specific information related to your JSP page.

Is that what you were asking about?
 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!