• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why use Struts over Servlets?

 
Greenhorn
Posts: 25
Firefox Browser Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was the question which was asked to me in an interview.

I replied saying there are many functionality incorporated in struts which helps us utilize them such as

1. if there are any mapping changes that needs to be performed we can change those in struts-config.xml and deploy it the change would be reflected unlike in web.xml where we have to restart the application.

The interviewer replied saying what if we have a tool in the future which would enable hot deployment, how would struts be different from servlets then.

2. I said, the validations can be performed collectively without re-writing of code in several servlets.

The interviewer replied saying that it does not bother him for the same validation code being used in several servlets.

3. I said, with the help of ActionForm we can auto populate the data and use it in our action class and process that data.

The interviewer replied saying he would use some other third-party tool to accomplish the same.

4. I replied saying all these functionality are combined in the Struts framework.

The interviewer replied asking what functionality in the struts-config xml file cannot be duplicated? - and i was not able to say anything more.

Could anyone be able to help me as to what answer the interviewer needed.
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's nothing in Struts that cannot be done without Struts using just servlets. Struts is based on servlets, after all.

The interviewer probably wanted to see how you react once you no longer know the answers.
 
Suvojyoty Saha
Greenhorn
Posts: 25
Firefox Browser Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim. But how should i answer such questions?
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if this guy was interviewing you or simply yanking your chain. Are you a vigorous and vocal proponent of Struts and maybe he just wanted to challenge you?

You use struts for the same reason I use JSF. Because they make you more productive, and they "normalize" the structure of the webapp, making it easier to maintain. And yes. JSF is, in fact one of those "third party" systems that could be used. In fact, I switched from Struts to JSF because I felt that it was more productive than Struts, but Struts is still very much alive and well in my town.

Personally, I can't think of anything in struts-config that other frameworks don't have an equivalent for, but that's hardly a reason all by itself.

As for doing everything in raw servlets, well, I could do everything in raw assembly language, too. But life is too short for that.
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should say exactly that - that there's nothing in Struts that can't be done without it, but that using a framework can save a lot of time.
 
Suvojyoty Saha
Greenhorn
Posts: 25
Firefox Browser Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim Holloway - I too am not sure as to why the interviewer kept asking me such questions But thanks for the answer.


Tim Moores - Thanks a lot for the answer
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:but that using a framework can save a lot of time.


Or perhaps not. My experience with the big frameworks is that they save no time at all. You just end up dealing with problems with the framework and working around things that the framework makes difficult instead of debugging your own code. It's often just a zero-sum game.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Tim Moores wrote:but that using a framework can save a lot of time.


Or perhaps not. My experience with the big frameworks is that they save no time at all. You just end up dealing with problems with the framework and working around things that the framework makes difficult instead of debugging your own code. It's often just a zero-sum game.



Sadly, there is some truth in that. However, I'm not quite that pessimistic. One advantage of using a pre-constructed framework is that when you do have problems, there are more people/books/websites to ask. Such as, for example, the CodeRanch.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But that is also true of bare-bones servlets and JSP.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:But that is also true of bare-bones servlets and JSP.



It's also true of assembly language. But that doesn't mean I want to go back to assembly language.

If a project is large enough and complex enough, you either end up writing - and debugging - the same stuff over and over again, or you start consolidating. Consolidate enough, and you've created your very own framework. If it's useful enough and adaptable enough, other people will pick up on it too. If it's really, really useful, it's likely to end up as a standard framwork of its own.

And then people will curse all the missing/buggy/confusing features.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or bitch and moan when non-backward compatible changes are made in version 2!
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Or perhaps not. My experience with the big frameworks is that they save no time at all.


Yes, individual experience does make a difference, and mine is quite different from yours. Especially web frameworks I've found to be great time savers. ORM frameworks - that's more of a mixed bag, especially once one gets to the point where the SQL generated by the framework does not perform well enough for a given task. I wouldn't consider something like Struts to be a "big" framework, though - it's quite limited in scope. Something like Spring, OTOH, tends to snake into the entire application architecture due to its far ranging components; caution is in order.
 
reply
    Bookmark Topic Watch Topic
  • New Topic