JSP Question

Hi,

Actually I am designing a group of JSP's which will connect to the EJB server in every successive screens....I am Looking up for the bean every time the JSP transfer control to the next page and although the code is working fine,I am not getting the expected result(i.e., the data comming from the server is not consistant).....I don't know weather I can Lookup for the bean only once for throughout the client session(i.e., for all the pages untill the client finishes his transaction) or not....If I can look up only once and can use the same instance then it will be well and good.....Can anybody tell me weather it is possible. If possible please tell me weather it is feasible and also what changes I have to make in the respective bean and the Jsp pages which is calling that bean.

Thanks in Advance,

Ram....

[845 byte] By [ramc352a] at [2007-9-28 19:21:37]
# 1

I know that the <jsp:useBean> tag takes a "scope" attribute, which can be set

to "request", "session", "application", etc.

Also, at least under Tomcat, the user session is encapsulated in an HttpSession that

might be able to store a reference to the bean once you've looked it up.

I apologize for not having more concrete answers; in my situation the department I

work for has Tomcat deployed, but not an EJB container. As a consequence, I haven't

been able to do much work with EJBs directly. It is my hope that what little

knowledge I do have gives you help, or at least leads you in the right direction!

cjbidlera at 2007-7-12 17:53:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

Thank you for the response Mr.cjbidler,I am trying out with the HTTP session as you hv said in your reply but, it is giving some strange error.I hv just assigned the object, which I looked up for the first time to the HTTP Session and tried to use it when I am coding for the next page but it is throwing JNDI Exception and not able to lookup....Please any body tell me how to achieve the same or else tell me where I am going wrong.

Thanks and Regards,

Ram...

ramc352a at 2007-7-12 17:53:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

Thank you for the response Mr.cjbidler,I am trying out with the HTTP session as you hv said in your reply but, it is giving some strange error.I hv just assigned the object, which I looked up for the first time to the HTTP Session and tried to use it when I am coding for the next page but it is throwing JNDI Exception and not able to lookup....Please any body tell me how to achieve the same or else tell me where I am going wrong.

Thanks and Regards,

Ram...

ramc352a at 2007-7-12 17:53:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

Thank you for the response Mr.cjbidler,I am trying out with the HTTP session as you hv said in your reply but, it is giving some strange error.I hv just assigned the object, which I looked up for the first time to the HTTP Session and tried to use it when I am coding for the next page but it is throwing JNDI Exception and not able to lookup....Please any body tell me how to achieve the same or else tell me where I am going wrong.

Thanks and Regards,

Ram...

ramc352a at 2007-7-12 17:53:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 5

> Hi,

>

> Actually I am designing a group of JSP's which

> hich will connect to the EJB server in every

> successive screens....

> Ram....

>

This is your first mistake. Read up on the model 2 pattern. Jsp pages should display data only. It is a serious design mistake to put business logic or dataaccess logic in jsp pages. This is best delegated to an abstraction layer that is not coupled to the view. You can then put the data you need to display in the request or session scope via a value object (VO) or data transfer object (DTO).

meadandalea at 2007-7-12 17:53:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 6
Ram, It will deteriorate the performance of the system, coz you need to make a jndi look-up in every jsp.Still your system need to make a request this is the best way jsp->java bean->EJB.Populate the jps with the data from the java bean.
ksanjaykrishnaa at 2007-7-12 17:53:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 7

OK, If I make jndi look up in every jsp page, then the state of the bean is lost and every jsp page will get the new instance of the bean right....In that situations in which I am going for the statefull session beans is it not possible to lookup for the bean only once and call the bean's business methods in the other jsp pages by only just passing the handle of lookup object...

Can any bosy tell me the exact solution for the same...

Thanks in advance,

Ram...

ramc352a at 2007-7-12 17:53:05 > top of Java-index,Other Topics,Patterns & OO Design...