Question re jspInit() and EJB initialization

Hi,

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.
skip1000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kiranhkCommented:
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

http://www.jguru.com/faq/view.jsp?EID=5314
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kiranhkCommented:
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

http://www.conceptgo.com/gsejb/sb03.html
0
petmagdyCommented:
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:

http://struts.apache.org/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

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.