Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Question re jspInit() and EJB initialization

Posted on 2004-10-22
Medium Priority
Last Modified: 2012-08-13

What is the purpose of jspinit() and what must you use it and when do you not need it.  Must an entity bean be initialized inside the jspinit() or not, if the EJB is to be used in the jsp?  Thanks.
Question by:skip1000
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

kiranhk earned 750 total points
ID: 12381270
jspInit basically is the method which the servlet container calls when starting the JSP first time when a request comes for it. this is called only once for the whole lifecycle. you can have some of the initialization code which u might need for all your subsequent requests. like looking up ur EJB/DataSource. If you dont have any requirement for resources common across requests then u dont do anything, just have ur plain jsp code.

for knowing how to write the code for looking up and jspInit check this out


Expert Comment

ID: 12381311
Its always better to have a Session bean as a wrapper for your Entity bean access becoz of Transactions, performance,  security.....

also check out this link for a tutorial

LVL 13

Expert Comment

ID: 12381351
Hi skip,

jspInit() is used for application parameters initialization it is called once first time u call ur JSP, like reading JSP configuration parameters, in ur case calling entity no don't lookup home in jspInit, call it normally from ur jsp body


ur code to lookup EJB and call


as u further go on learning J2EE u will learn that according to J2EE Blueprints JSP is not the place to call business Logic u have to use MVC (Model View Control) and its newer version Model2 frameworks like Jakarta Struts open source Model 2 framework

to look in struts refer to:


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes Administrators rights are not enough. These cases call for the SYSTEM account. The process in this article outlines the steps required to execute commands using the SYSTEM account.
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question