Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to handle session in EJB

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I make a small loging application using ejb

this is loging jsp


this is userAuthorise servlet


this is sessionbean



this is entitybean



This application work fine.
No problem.
Anyway i need to know how to add session to this application.
Is it add to servlet or Ejb?
if it should EJB ,HOW?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what "add sessioN" means, but you can choose to use an HTTP session or an EJB session as your needs require. Which one do you need?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sesion mean conversional state.
or session mean i need to identify user when his made a second request that this is a his second request?
how can i archieve this using EJB?
I know how to do this using Servlets.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a stateful session bean.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HTTPSession on to the JSP Page will be taken by the EJB Container and it will be rresponsible to maintain the Session in case of the Statefull Session Bean .

What Paul mentioned is right , use Statefull Session Bean

 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use Statefull Session Bean

You would still need a session (or the equivalent of it) on the client to store a Handle to the stateful session bean.

ram.
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this example i used Entity beans for Persistance.
I read that Entity beans are the worst part of EJB3.SO can we replace the Entity beans with Anyother thing?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samanthi perera wrote:
I read that Entity beans are the worst part of EJB3.SO can we replace the Entity beans with Anyother thing?


Where did you read that? As I said in another post, there are no entity *beans* in EJB3. They are just entities. And I have never heard that they are the worst part of EJB3. EJB2.x entity beans, yes, that's a different story.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this example i used Entity beans for Persistance.


By the way, how is that related to the original question that you started off with in this topic?
 
Krum Bakalsky
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this example i used Entity beans for Persistance.


Nope, you are wrong! You are not using entity beans at all! What you use, is called "entities", not entity beans.
Please put some effort to use the proper terminology.
Entity beans are EJB 2.1 legacy, and are managed by the EJB container (so they really are type of EJBs)
Entities are a JPA artifact, and they are not managed by the EJB container, but by the JPA provider instead (so they are not EJBs at all)

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic