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
  • 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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Are you in the migration process of your Exchange to Exchange Online? Be aware of customized solutions developed on the transport role on your old Exchange server. They might not be convertible to Exchange Online!
In an Exchange Crossforest migration, the distribution groups can be a very complex operation that would cause loss of time, lots of issues and continued headaches if not solved in a timely manner. I had to do a similar project so I created a sc…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…

619 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