It’s just data

REST via JSP

Bill de hÓra: I’m wondering how would one produce a URL space for a blog style archive, using Servlets+JSP, and do so in a way that isn’t a CGI/RPC explicit call?

Perhaps via URL Rewrite Filters?


That would be a good approach.  As would a servlet that uses RequestDispatcher to forward requests to templates (this is probably what UrlRewriteFilter does under the covers).

Posted by Karl at

Karl, I guess that would look something like this.

Posted by Sam Ruby at

I don’t see where to post comments on Bill’s weblog, so here I am...

Would Url Rewrite Filter qualify for "a framework, however 'micro'"?

A counterfactual question to ask next is, if we didn’t start out with a URL space in mind, would Servlets+JSP naturally lead us to CGI style call or not?

As far as I remember, any servlet could be seen as a controller (sic) for a single resource, collecting GET/POST/PUT/DELETE etc. requests directed to that resource. You would probably not end exposing directly file names in URIs, though, as in your example of the blog style archive.

Posted by Giulio Piancastelli at

Goes back to this question: Why Do Web Server APIs Suck So Much? [link]

“URIs are the lynchpin of the Web; to get the full value of the Web infrastructure, you need to be able to identify every interesting part of your Web application with a URI. Unfortunately, common Web APIs don’t encourage this, or even actively discourage it.

...

[The Servlet API] stuffs a number of URIs (and therefore resources) into a single container, making it difficult to model an application as the transfer of state.”

But there may be hope for the frameworks - Parameterized REST URLs with Spring MVC [link] - seems like a fairly painless solution in terms of code.

Posted by Harry Fuecks at

Servlets+JSP design answers

Earlier I asked: “I’m wondering how would one produce a URL space for a blog style archive, using Servlets+JSP, and do so in a way that isn’t a CGI/RPC explicit call?” I got some answers, all good: Sam Ruby: "Perhaps......

Excerpt from Bill de hÓra at

Use RequestDispatcher to forward the request onto a JSP from a servlet. Configure the servlet on a url prefix and using URITemplates for routing and reparing resources.

It is trivial once you stop thinking in terms of 1 url = 1 servlet/JSP. Even outside of ReST, most MVC or FrontEnd controller style frameworks are written this way.

Posted by Austin King at

The IBM Press Room has been using servlet filters to offer pretty URLs since late 2005 on WAS 5.1/J2EE 1.3/Servlet 2.3.  In addition to finding the particular piece of content you’re looking for, it will filter generic requests to the press room you’re most likely looking for for based on your browser’s preferred locale.  It’s only been implemented for the US and Italy so far, but will be boarding other countries later this year.

A couple examples of content id and locale masking:
http://www.ibm.com/press/us/en/pressrelease/7778.wss
http://www.ibm.com/press/it/it/pressrelease/22004.wss

And a high level poster session I put together on how it was implemented via servlet filters and request wrappers:
Creating short, intuitive and search engine friendly URLs with servlet filters

Posted by Daniel Krook at

With the Restlet framework, you can directly specify your URI mappings using the URI template syntax, for both server-side and client-side URI resolution. See this tutorial example.

In addition, a Restlet application can run either in a standalone JVM or embedded with a Servlet container using a simple adapter class.

Posted by Jerome Louvel at

The answer on aggregate seems to be: use more than Servlets+JSP. That’s what I thought it might be.

I find it illuminating that the foundation web technology for Java/EE doesn’t support anything other than CGI. I will be interested to see how Java/EE evolves in that regard.

Posted by Bill de hOra at

Simple RESTful URLs with JSPs

Bill de hOra posted an interesting question the other day, that has to do with mapping views to requests, cleanly,......

Excerpt from paradox1x at

Add your comment