views:

599

answers:

4

First, some background:

I will have to work on code for a JSP that will demand a lot of code fixing and testing. This JSP will receive a structure of given objects, and render it according to a couple of rules.

What I would like to do, is to write a "Test Server" that would read some mock data out of a fixtures file, and mock those objects into a factory that would be used by the JSP in question.

The target App Server is WebSphere and I would like to code, change, code in order to test appropriate HTML rendering. I have done something similar on the past, but the JSP part was just calling a method on a rendering object, so I created an Ad Hoc HTTP server that would read the fixture files, parse it and render HTML.

All I had to do was run it inside RAD, change the HTML code and hit F5.

So question pretty much goes down to: Is there any stand alone library or lightweight server (I thought of Jetty) that would take a JSP, and given the correct contexts (Request, Response, Session, etc.) render the proper HTML?

A: 

jetty and tomcat

those may be not light enough for your tastes though.
you'll find plenty of users and support on SO for tomcat, so that counts for something.

popcnt
Tomcat won't cut it. I have to be able to start it from a Java main(). Jetty will probably be an alternative. But: is there a JSP rendering API out there?
kolrie
Tomcat is written in Java - how do you think it starts if not via a main() method?
oxbow_lakes
@kolrie: Tomcat also comes with a built-in JSP renderer named Jasper... It could most certainly be adapted to suit your purposes. Jasper is used with Jetty as well. Cactus (another from ASF) does rich testing framework, similar to what you describe as needing.
popcnt
A: 

There is none ( afaik ) .

The only workaround I could suggest is to use Velocity instead. But, of course you would have to resign to jsp altogether and that could not the an option.

IF you do then you can isolate your test with Velocity move the result into a web.

Here's an article on how to use Velocity + Ruby ( or JRuby ) for an standalone solution.

http://martinfowler.com/bliki/JRubyVelocity.html

OscarRyz
A: 

I've never used JSPs, but I have played around with OOWeb. It's definitely lightweight, and follows the request/response model, but you'll be hard pressed to connect it with your JSPs without a lot of glue.

A couple lightweight containers are listed here. It looks like Tiny Java Web Server in particular is actively being developed. Unfortunately there's not much documentation available for it.

Nikhil Chelliah
Thanks! One minor remark: this article seems very old :-)
kolrie
naah 2 yrs. old only
OscarRyz
Now that I notice it, most of those posts were from 2004 - the last one alone is from 2007. One of those suggestions (TJWS) is still active, according to SourceForge, so I'll edit that in...
Nikhil Chelliah
+1  A: 

You need more than a web server. You've got to have a servlet/JSP engine, so there's no getting around that.

Jetty's quite light. Maybe Resin deserves a look, too.

duffymo