aspose file tools*
The moose likes Servlets and the fly likes Servlet limitations? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet limitations?" Watch "Servlet limitations?" New topic
Author

Servlet limitations?

Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Hello,
I am interested in using servlets to develop an on-line application because I already know Java. The problem is the book I have doesn't really tell me the limitations of servlets. Is the whole core java API available?
For example, one concern is that a servlet will not be capable of creating and saving out image files using the java.awt.image.BufferedImage and com.sun.image.codec.jpeg packages. Can anyone tell me if there are any features like this that may not be useable in servlets please?
thanks,
Ben.


SCJP 1.4, www.gsi3d.org.uk
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

The J2EE environment is layered on top of the core Java libraries. The only limitations are those having to do with where you are running. For example, you can manipulate images, but you can't use Swing, since Swing runs on the console, and the console's likely to be locked in a dark room somewhere.
One limitation in the graphics environment however, is that Java is extending the system's native graphics environment - so there'd better be one. Unix users find out about this when they try and use the graphics services and there's no windowing system (such as X windows) running on the machine.


Customer surveys are for companies who didn't pay proper attention to begin with.
hanumanth reddy
Ranch Hand

Joined: Jun 12, 2000
Posts: 118
servlet appliaction are not scalabe.


<a href="http://www.jobklub.com" target="_blank" rel="nofollow">http://www.jobklub.com</a><br /> 'Add Job To Life'
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
hanumanth - I am sure we would all like to know your reasoning for that statement.
Bill
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
I see.
So, I currently have a stand-alone Java app which creates a graph which can be saved as a jpeg. This graph is drawn by over-riding a JPanel's paintComponent() method. Therefore I can't do the same thing in a servlet I assume if swing isn't available? Can I use AWT components? What about the canvas class? Do you have any ideas what the best way to draw my graph might be in order to save it out later as an image?
thanks for the help,
Ben.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

Your main limitation on use of graphics routines is you can use them on memory objects but not on objects that rely on actual physical hardware. For example, you can create/manipulate graphics bitmaps, but at best, trying to use a ListBox control would cause it to pop up in that locked room I mentioned.
On the old Commodore Amiga OS, the graphics services, the services relating to manipulating overlapping graphics areas and the services relating to actual user-interface controls (Windows & widgets) were discrete packages. AWT crams all these into one, so the distinctions may not be so obvious. I can't actually think of any use for Swing outside an interactive UI, however.
Using JPanels and paint() methods isn't likely to work well. When synthesising bitmaps or vector graphics, an AWT canvas and direct rendering is moe appropriate. Paint() is intended for refreshing images, and a graphic not being obscured by overlapping windows and the like doesn't need that.
You may find it more productive to simply go out and buy a commercial Java graphing package.
Graeme Brown
Ranch Hand

Joined: Oct 13, 2000
Posts: 193
Ben
It really depends on how you want your users to interact with your app. You say that the existing app produces a graph that can be saved as a jpeg.
If you amend it so that the jpeg is automatically created on the server, then you can embed that in the HTML returned to the user.
A possible solution, but don't know if it will work for your situation.
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Tim, Graeme...
Thanks for your ideas. What Graeme suggests about creating the jpeg on the server and then linking to it from an html file is exactly what I want to achieve, but according to Tim this will be difficult because my existing graphing application is swing based. This is (sort of) how it works...

At the minute drawing on g2d is done within paintCoponent() of a JPanel.
I just need to know whether I can hope to use this general approach using a servlet, assuming I work round the use of paintComponent() - e.g. by drawing the graphics in memory, rather than on screen in a window. Buying graphing software to do this for me is a non-starter; it doesn't exist for the types of graphs and plots I'm thinking of which are highly specialised and some are of my own design. The budget is also small;-)
thanks,
Ben.
Graeme Brown
Ranch Hand

Joined: Oct 13, 2000
Posts: 193
Yup that approach will definitely work. I have previously written an app using that technique, with in-memory painting.
hanumanth reddy
Ranch Hand

Joined: Jun 12, 2000
Posts: 118
Limitation of servlets
memory leakage while compiling servelt.
no support for awt or graphics.
and Servet developer need to know the basic html css and javascript etc..(along with the java)
Graeme Brown
Ranch Hand

Joined: Oct 13, 2000
Posts: 193
Originally posted by hanumanth reddy:
Limitation of servlets
memory leakage while compiling servelt.
no support for awt or graphics.
and Servet developer need to know the basic html css and javascript etc..(along with the java)

memory leakage while compiling servlet - get a decent compiler!
no support for awt or graphics - duh, that's the point of servlets! Thin clients.
Servlet developer need to know... - Thats where JSP comes in. Don't pollute java code with HTML, put it in a JSP. If you work in a team environment then the JSP can be written be a web developer, leaving programmers to work on the business logic.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5

memory leakage while compiling servelt.
no support for awt or graphics.
and Servet developer need to know the basic html css and javascript etc..(along with the java)

memory leakage - sorry you have a problem, nothing to do with scaling
support for graphics - open your eyes, every servlet book - mine included - shows how to generate graphics dynamically in servlets
Servlet developer needs to know HTML, CSS - well DUH! anybody doing anything on the web with any technology needs to know something about the standards. If your team is divided into web designers and programmers, thats what JSP is for. Anyway, nothing to do with scalability.
You forgot to whine about having to know XML as well. Another DUH! Anybody trying to work in this field better be up to speed on XML.
Bill
 
wood burning stoves
 
subject: Servlet limitations?