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

servlets event-driven?

 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Can servlets be called 'event driven'? We normally associate that term only with VB, but can it be associated with servlets?
Since a request is needed to 'trigger' the servlet, can we say the 'request event' fires the servlet?

In a broader sense, everything is event driven, no code executes 'on its' own'. It is either initiated by the user or on the completion of a timer etc. but applying this specifically to servlets, a servlet can only be triggered by a request-event. so can i safely call servlets event-driven???
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can call the servlet on load event, prior to any request. Ofcourse init() method would get called.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In reply to Adeel's post:

In VB as well, the Form.Load() procedure etc is also called when the form loads for the first time only, but after that the entire thing becomes event-driven.

Now continuing on that analogy, the init may/may not be called on server startup, but after that the servlet behaves in an event-driven manner??

is my post a valid train of thought or plain rubbish???
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say that while web pages themselves can be event driven (via javascript event listeners) and while there are listeners for certain events within Servlet Containers (context and session listeners), servlet programming (or any web programming environment) is request driven and doesn't really fit the "event driven" model.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request driven

It sounds better.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes. 'request driven' definitely sounds better.

The Java equivalent of 'event driven'.
 
Gemma Cameron
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dude!

That'll sound great in my dissertation!!!

Anyone got any other great knowledge to bestow about servlets which I may not already now to pop in there? ( :
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, component-oriented frameworks like Tapestry and JSF can make your webapp "feel like" it's event driven. You might want to check one of them out. It makes coding webapps quite easy.
[ May 07, 2005: Message edited by: James Carman ]
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes James,

you are right. I use Struts and yes, that can make it 'feel' more request driven.

taking an MVC framework into consideration:

1. a client requests a server for some resource.
2. based on that request, the controller fires an event to service the request.

so, the trigger is the request, but now this becomes a two step process of request and event ???
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Neeraj Dheer:
yes James,

you are right. I use Struts and yes, that can make it 'feel' more request driven.

taking an MVC framework into consideration:

1. a client requests a server for some resource.
2. based on that request, the controller fires an event to service the request.

so, the trigger is the request, but now this becomes a two step process of request and event ???



Of course it's request driven. All webapps really are. The key is that Tapestry and JSF make it feel like it's event-driven by doing a lot of work for you. So, yes, it does become a two-step process to take the request and make it look like an event, but that is done for you with frameworks like those. Struts doesn't do that at all, really. It's not a component-based framework.
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's useless discovery.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by D Rog:
I think it's useless discovery.


What do you think is "useless discovery"?
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's useless discovery.


I think he is talking about servlets being request-driven.

The topic here Rog was servlets being 'event' driven.
 
Aneel Ansari
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my opinion we can call servlets (event driven)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic