File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes servlets event-driven? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "servlets event-driven?" Watch "servlets event-driven?" New topic
Author

servlets event-driven?

Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
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

Joined: Aug 15, 2004
Posts: 2874
We can call the servlet on load event, prior to any request. Ofcourse init() method would get called.
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
request driven

It sounds better.
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
yes. 'request driven' definitely sounds better.

The Java equivalent of 'event driven'.
Gemma Cameron
Greenhorn

Joined: Feb 15, 2005
Posts: 14
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

Joined: Feb 20, 2001
Posts: 580
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 ]

James Carman, President<br />Carman Consulting, Inc.
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
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

Joined: Feb 20, 2001
Posts: 580
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

Joined: Feb 07, 2004
Posts: 472

I think it's useless discovery.


Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Originally posted by D Rog:
I think it's useless discovery.


What do you think is "useless discovery"?
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
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

Joined: May 16, 2005
Posts: 7
in my opinion we can call servlets (event driven)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlets event-driven?