I can use jsp to write a web application, I can use jsp to execute a SQL statement to maintain database, why I need a session bean? What make the session bean so special? thank you.
Asked
Active
Viewed 283 times
3 Answers
0
The session bean allows you to carry user-specific information around from page to page, instead of you having to look up a cookie in a database to get the logged in user every time a JSP-page is served.
In other words, it is the facility that allows users to log in to your web site.

Thorbjørn Ravn Andersen
- 73,784
- 33
- 194
- 347
-
2With a SQL query for every JSP-page served? Guess which approach scales best? – Thorbjørn Ravn Andersen Dec 09 '10 at 16:38
0
It holds data through out the session,
For Example :
In your Web Application you have user name , user profile data that you need to display on each page.
It is obviously not good practice to fetch it from DB for each page better to take it once and store it in session bean

jmj
- 237,923
- 42
- 401
- 438
-
I can get it once, and store in the cookies, and display it again.... still don't know why the session bean is important....Also, why it is not good practice? – Tattat Dec 09 '10 at 16:40
-
@Tattat Cookies are meant to store a key which will map with your session on server and on server 's memory these data will be stored – jmj Dec 09 '10 at 16:50
0
Personally I would never put sql statement execution ON a jsp. that should be down in the model somewhere.

jaydel
- 14,389
- 14
- 62
- 98