This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

init of servlets and jsp

 
vara prasad
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
 
Jeroen Wenting
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.
 
Adeel Ansari
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.
 
Dan Novik
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.
 
ramprasad madathil
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.
 
James Carman
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic