Two Laptop Bag*
The moose likes Struts and the fly likes how many servlets needed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how many servlets needed?" Watch "how many servlets needed?" New topic
Author

how many servlets needed?

Tony Smith
Ranch Hand

Joined: Jul 07, 2007
Posts: 229
Hi, I am new to Struts. The question is, seems like if you are using struts, there is only one central actionservlet that works as the main controller. So, besides that servlet, there is no need to create additional traditional little servlet classes in other places right? Or is there places where you still need to create class and extends httpservlet?
[ September 22, 2007: Message edited by: Tony Smith ]
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
No need for traditional servlet when we are in struts.
Tarun Yadav
Ranch Hand

Joined: Sep 20, 2007
Posts: 134
Originally posted by vidya sagar:
No need for traditional servlet when we are in struts.


Well, it depends, right? If I have an ImageServlet or a FileUpload/ FileDownload servlet, or a need for the same, then I would be using servlets. Or perhaps I'm adding Struts to an older project, I would have to work with servlets in that case also.

So, I guess it depends on your requirement. There aren't any hard and fast rules; if you need to and there is no better way to do it ( say in your Action classes ) then by all means, use servlets.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Tarun Yadav:

Well, it depends, right? If I have an ImageServlet or a FileUpload/ FileDownload servlet, or a need for the same, then I would be using servlets.

Not necessarily. Struts has utilities for downloading image or other files and for uploading files. There's no need for a servlet to do these things in a Struts application.
Originally posted by Tarun Yadav:
Or perhaps I'm adding Struts to an older project, I would have to work with servlets in that case also.

Again, not necessarily. You have the option of converting the Servlets to Action classes. It still isn't necessary to use Servlets.
Originally posted by Tarun Yadav:
So, I guess it depends on your requirement. There aren't any hard and fast rules; if you need to and there is no better way to do it ( say in your Action classes ) then by all means, use servlets.

I would agree with the fact that there might be occasions where one could choose to have Action classes and Servlets interacting with each other in the same application. However, the reasons for doing so are generally things like bugetary contstraints or other reasons external to good architectural principles. I don't agree that this is a good practice, or one that should be chosen without carefully considering other options. The confusion engendered by this type of architectural hodgepodge is generally not worth it.
[ September 24, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Tarun Yadav
Ranch Hand

Joined: Sep 20, 2007
Posts: 134
Hm, alright, I get the idea now

Originally posted by Merrill Higginson:

Again, not necessarily. You have the option of converting the Servlets to Action classes. It still isn't necessary to use Servlets.

Though what I meant here was that while you're in the middle of porting an old app to Struts; this is what I'm doing now. I've to move my old application that's in use to Struts. Now I've only just started with Struts and the app needs to be in use while I'm working on it. So I'm gradually moving modules; which means that I still have to interact with my old servlets for things like generation of reports in Excel, which is handled by one servlet.

Basically, what I was trying to say was that you might have to work with servlets with older apps so you should have an idea of how it works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how many servlets needed?