tags:

views:

68

answers:

2

I am new to JSPs and Servlets - I am wondering if there is any way for a JSP of delegating to a servlet the generation of given areas of the page such as custom controls (AWT stuff and such).

The reason why I am looking into this is that JSP pages can get really messy really fast.

Examples appreciated!

+1  A: 

You can make a subrequest and have the subrequest's output sent to the client instead of being buffered. For example <c:import url="path/to/servlet"/> (or use jsp:include).

If you want to call some custom Java code to produce output during a JSP page, you might consider using a custom JSP tag instead of a servlet, though. There should be less overhead since the tag is basically just instantiated and called, and the scheme for passing parameters to tags is much cleaner.

araqnid
thanks - looks like what I was looking for - can you point me to any resource/example you think it's worth having a look at?
JohnIdol
A: 

Aside of <jsp:include /> (or <c:import />, or custom tags), and if your goal is to make the JSPs more maintenable, take a look at JTPL templates: http://jtpl.sourceforge.net/ - old, but usefull stuff :)

You may also consider use of some of component MVC frameworks - an implementation of JSF, for example.

david a.