I’m building a JS client and want to be able to quickly test stuff locally during development. I need a mocked server for that.
Since I’m using Maven and its Jetty plugin, I easily got a servlet up that sends responses. Now I would like to slightly improve on this by adding JSP for the view.
I’m already familiar with Struts (and Wicket), but since JSP and Servlet support is already built into Jetty, I thought I could just throw some servlets and some JSPs in there, connecting them with configuration (in the web.xml?) without resorting to a major framework.
Googling so far brings me only general architecture and specification stuff or Struts examples.
JSPs are servlets. So everything you do in a servlet can be done in a JSP directly (or nearly everything).
It’s however a bad practice to put Java code into JSPs. So you might just use servlets for the controller logic, and then use
request.getRequestDispatcher("/somePage.jsp").forward(request, response)to dispatch the request and response to the JSP. That’s the absolute minimum an MVC framework does.More explanation of servlet basics, inclusing some example code and further links on the wiki page for the
servletstag.It’s unclear what you expect from your minimal framework. But using a framework like Stripes, for example, is pretty straightforward and does all this for you, by adding some lines in the web.xml and some annotations in Action classes replacing the servlets as controllers.