• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reasons Never to use Servlets  RSS feed

 
Samuel Mendenhall
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a new hire at a small company as a software dev. I have been working on an initial application all in jsps becuase I was instructed too. Well, today, I went to integrate my first Servlet into my project becuase I got tired of the bloat in the JSP.

I was instructed that the web.xml is NEVER to be touched, and that they don't use Servlets, they emulate them in JSP if they have too. Their reason was becuase the web.xml is too volatile and complex to edit. And if an error gets into the web.xml, then there could be mass problems on their production server.

I was completely speechless and blown away. In my mind, Servlets make J2EE, what reason is there to even use j2ee if not for servlets. We might as well use php for that reason, becuase we are forgoing the major advantages of cleanly separated code.

Does anyone else here share this same sentiment, or have encountered it?. I have never heard of any other organization or person thinking this way. I want to make sure I'm not being irrational, which I don't think I am. I follow every ounce of news in the Java world, have I've never heard this argument raised against using Servlets.

Can someone give me some solid arguments to present to the Senior dev and my supervisor, that they NEED to use servlets for MVC, not emulate them in JSP. My main arguments are speed, maintainability, and standards.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Samuel Mendenhall:

Does anyone else here share this same sentiment, or have encountered it?.

I think you'll be hard pressed to find any regulars here who share this sentiment. And no, I've never encountered it.

[Samuel]Can someone give me some solid arguments...

It sounds like you already understand the value of servlets... fully.
From the sounds of it, there isn't an argument that will sway this group; that they've already made up their minds.
I think you've found yourself a genuine pointy haired boss.

If you want to give them links to a multitude of other people preaching your same message, search this and the JSP forum with the keyword 'MVC'.
Add my name or "Bear" to the search to narrow it down some.

You have my deepest sympathies.
 
jeff ukridge
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is an article that may provide you with some points to make during your next software design review or whatever you have at the office.

http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html

It's a little dated and it may not provide you with anything, but it's worth a look.
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't believe your argument for speed is the strongest.
Sure there is the initial translate/compile hit when you first access a jsp, but after that it is just a servlet.

Standards: you could have an argument here. There are many proponents for the "scriptlet-free" JSP.

Personally what I find more convincing is that for writing java code, you can't beat a java IDE. Compile time checking, syntax highlighting, code lookup etc etc - you lose all that if you start putting java code in a JSP.
Productivity baby!

Also if you change a class/method signature in a tool like Eclipse, it will pop up errors in every java class you call that method from. However the JSPs won't complain until you compile/access them. It is much easier for those mistakes to slip through and get deployed.

Now I can understand their point about not wanting to edit the web.xml file often. (even if I don't necessarily agree).
Maybe you could introduce one servlet, which will let you call others. Something like the Invoker servlet does (but not the invoker servlet)
More like the struts controller servlet, which reads a seperate xml file to find out which actions/servlets it can invoke.

That will mean that you only ever have to add one servlet to web.xml - the controller servlet. After that you never need touch it again.
Perhaps you can sell them on that idea?

As a last resort, do the right thing, and go writing your business logic into beans, and then just call those actions from the JSP.
One line of scriptlet code in a JSP is better than hundreds.

Good luck,
evnafets
[ November 23, 2005: Message edited by: Stefan Evans ]
 
Samuel Mendenhall
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for all the responses,

They are committed to MVC all I have to convince them to do is use servlets. My main reasons are for using them is becuase of the niceities of Eclipse as Stephan said. IDEs make developing 10x easier, but my superiors are hardcore notepad guys, although we all still use Eclipse.

Stephan, I will do what you said and as a last resort use Beans to hold all of the logic. There is one problem. I used a bean the other day, and they saw what I did, and they were VERY uncomfortable with the fact the I named it SoAndSoBean, and they were even more uncomfortable with me reading in the result set into an arraylist and pushing that to a view. They want the JSP to be updated every time a row in the table gets read. So in the while of the result set, I have to do out.print then an out.flush.

Is there any way to mimic this behavior in an MVC approach, nothing comes to mind.

Thank you Jeff for the link, the first few paragraphs has good points.

They also claimed they had implemented Struts and Spring using only JSPs, no servlets, is this possible?

Samuel
[ November 23, 2005: Message edited by: Samuel Mendenhall ]
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my understanding JSP is the same as servlet, it only eliminate compilation steps. I am not sure, but probably you can't inherit one JSP from another. Anyway, new programming paradigm eliminate inheritance in favor of using templates.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Samuel Mendenhall:

they were VERY uncomfortable with the fact the I named it SoAndSoBean, and they were even more uncomfortable with me reading in the result set into an arraylist and pushing that to a view. They want the JSP to be updated every time a row in the table gets read. So in the while of the result set, I have to do out.print then an out.flush.
[ November 23, 2005: Message edited by: Samuel Mendenhall ]


My sincerest sympathies to you Samuel.
Any chance of getting another job! To me, it looks like you will be wasting your time there.
Just curious, all these superiors with these brilliant ideas, are they developers or just managers who have read a few books on J2EE/MVC?
And these people are using Spring!! Rod Johnson must be turning in his err.. Aeron chair right now

Sorry, I have nothing helpful to offer....
[ November 23, 2005: Message edited by: Sonny Gill ]
 
Samuel Mendenhall
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must come to the defense of my superiors, they are excellent programmers, this is the only difference of opinion I've had with them so far. The one guy is a genius in some of the code he writes. They are really great guys, just a bit stuck on old ways when it comes to Servlets.

And the job is phenomenal, it is exactly what I want to do, I get to code solid all day long on great projects with no beaurocratics. It is a small company, and there only several of us developers. I used to work at IBM, can't say I miss it in relation to this job.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that's the case, maybe it's best to suck it up for this project and follow their practices.

Then, if you get an opportunity to build a smaller or in-house project, ask if you can do it your way and build it as you see fit. That smaller project will then be your 'proof of concept' that you can use to show that there is nothing unstable about having a web.xml file with explicit servlet entries and mappings.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoa, how can anyone say that debugging an errant web.xml is trickier than debugging a load of JSP scripts! You have my sympathies, but do try the above suggestion - it might allay their fears when you pull it off.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my short career, relatively, I have never done JSPs without servlet nor just servlets without JSP. May be I have joined the group after MVC.

Be there. Follow their practices. Because you are not going to have any other better place to seek a new good job. All the best.

Cheer up. Its just the trailer of this false world.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
to show that there is nothing unstable about having a web.xml file with explicit servlet entries and mappings.


Especially if you have unit and acceptance tests to verify that it is correct.
Great advice Ben. Hope it works out for you Samuel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!