• 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

Servlets and JSP?

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working for somebody that wants to convert his servlet classes to
jsp pages. So that he can dynamically make changes to the classes without having to start and stop the server.


Is their any easier way to do it then just to convert all the pages to jsp's.

The main objective is so we don't have to start and stop the server ever time we update a class.

We are using the Jetty server. But we are running these classes on different webservers as well.

Thanks for any help.
[ August 11, 2008: Message edited by: Bear Bibeault ]
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my opinion that is a real bad reason for converting servlets to JSPs. Moving all your servlets to JSPs will make developement harder because the error messages get skewed and hidden.

JSPs should be used for display purposes only. Convert the display part of your Servlets to JSPs. The control part of the servlets should stay in a servlet.

If you want to facilitate testing your code then
1) Use a development-only server until the code is finalized, then pack it and move to the deployment server.
2) See if there is a manager package for Jetty that will allow you to restart individual contexts

I know other servers (like Tomcat) have a manager application that allows you to restart individual contexts. Most servers based on Tomcat (like Glassfish) do as well. I don't know Jetty though.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
putting server aside, it is very unlikely to have all jsp pages in large projects. You should probably look into model-view-controller (MVC) design pattern.
 
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

Originally posted by Steve Luke:
In my opinion that is a real bad reason for converting servlets to JSPs.

I'll state it a bit more strongly and say that that is borderline insane! It goes in the exact opposite direction of all notions of best practices and logic. You can tell them I said so.

In order to accomplish this, you'd have to have all Java code in the JSPs. No classes, no beans, no tags, no tag files. What a complete and utter mess it would be!

Insane!
[ August 11, 2008: Message edited by: Bear Bibeault ]
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought it wasn't a good idea but I cann't argue with the boss to much so.


In order to accomplish this, you'd have to have all Java code in the JSPs. No classes, no beans, no tags, no tag files. What a complete and utter mess it would be!


What I think he wants is to code all the servlets into jsp pages.
And if a servlet extended another class convert it into a jsp include statment. I know this will not work very well.

Does anybody know how to beable to get the updating of a file without shuting down the server?

I know with jsp you can set the time for it to recompile updated jsp files.
But when I make a change to a servlet file I want it, to act exactly like a jsp. In that when I modify a servlet I don't have to shutdown and restart the server before the changes take place.
 
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

Originally posted by Sam Doder:
I thought it wasn't a good idea but I cann't argue with the boss to much so.

I think it's perfectly reasonable, in fact an important part of an engineer's job, to bring up objections to bad ideas. All in a professional way of course.

And if a servlet extended another class convert it into a jsp include statment. I know this will not work very well.

It won't work at all. Including isn't anywhere the same thing as extending. You'd need to flatten any extending into a single class.

Does anybody know how to beable to get the updating of a file without shuting down the server?

You rarely need to shut down the server. Most app servers will allow you to simply restart an affected web application. Does your boss know anything about web applications?

I know with jsp you can set the time for it to recompile updated jsp files.

Not really. The JSP engine detects when the JSP has changed and re-translates it. It then uses a custom class-loader to reload it on-the-fly.

But when I make a change to a servlet file I want it, to act exactly like a jsp. In that when I modify a servlet I don't have to shutdown and restart the server before the changes take place.

As I said, you don't need to shut down the server. Simply restart the web app. But there's no getting around the web app restart.
[ August 11, 2008: Message edited by: Bear Bibeault ]
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

As I said, you don't need to shut down the server. Simply restart the web app. But there's no getting around the web app restart.



When I said shutdown the server I meant shutdown the application server.
NOT PHYSICAL SHUT DOWN THE MACHINE!
Because I don't want to shutdown the whole entire application server either, because I have more then one application running on the application server.

So is their away to only shutdown/restart a piece of the application server.

Because if I can get the jetty server to only restart a certain application when it is updated then I may beable convince him of not doing it this way.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sam Doder:
Because I don't want to shutdown the whole entire application server either, because I have more then one application running on the application server.

So is their away to only shutdown/restart a piece of the application server.

Seems to me that Bear suggested doing exactly that.

I spent a few minutes googling and found the Jetty documentation page. It had a link labelled "Hot Deploy" -- which is precisely what you are asking about. And I see that you can get commercial support for Jetty. You (or your boss, I guess) should consider signing up for that. It might save a lot of fumbling around in the dark.
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that.
However we have web application servers other then jetty.

So I need a general way to support this.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam, Listen to the advise upthread. This is a really dumb idea, its contrary to the whole "separate business logic from presentation" mantra that has been the goal of developers for the past decade.
 
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
Yes, I never meant shut down the machine. Any app server worth its salt will allow you to stop and restart individual applications.

Send your boss here. We'll set him straight.
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys for your help.
I will bring this up and let him.
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic