tags:

views:

33

answers:

1

Background: Migrating an application from ball of mud to MVC. Many classes contain HTML building methods. Refactoring as I add features, I'm not looking for a complete rewrite.

I'd like to build some smaller views but need to render them in between some serious string building.

To compose my views is a jsp I would use <jsp:include /> tags. Is there similiar functionality I can call from a class? I'm looking at java.net.URL but it will require a little plumbing. The class already depends on the request object.

Thanks in advance.

+2  A: 

Depends on what you mean "call from a class". If your "class" is actually a Servlet, then you can get the RequestDispatcher from the servlet context, and call the include() method from it. If your class is called from a servlet, you can pass the RequestDispatcher into it.

But that's a really bad idea.

Based on your description, I'd think of using a taglib for my "serious string handling", and invoke those tags from the view.

kdgregory
The Class is a POJO with an awesome getSomeSeriousHTML() method. It's looks like an inside out jsp minus the Servlet interface. Thanks and happy hunting.
jms