views:

213

answers:

1

Hi,

This is related to this question:

how-can-i-port-a-legacy-java-j2ee-website-to-a-modern-scripting-language

but with a narrower focus.

We're pretty much rewriting our legacy Java app from the ground up for a variety of reasons, but attempting to keep the user interface pretty much the same.

In one of the answers, someone said:

Pick representative pages and rework them into the appropriate templates. You might make use of some legacy JSP pages. However, don't waste too much time with this. Use the HTML to create Django templates.

The thing is, the application has about 15 different "front pages", each of which is largely composed of an appropriately mixed&matched subset of ~100 jsp files. I believe the partitioning of content in the jsp files is probably the partitioning that I would want to use for the Django templates; thus I'd rather convert them to templates than start with the HTML and re-do the work of figuring out the proper partitioning.

So, I'm really hoping there is a reasonable way to do this conversion.

I'm a Django newbie & have never worked with javascript (tho other folks on my team have), so any help would be greatly appreciated: if you can recommend an automated or semi-automated tool, or suggest a basic approach, tips & tricks, advice, horror stories..

Thanks in advance!

Edited in response to Vinay's answer:

I think it is fairly vanilla jsp, with no third party libraries involved. There are scriptlets, but they are well-segregated into their own files.

At this point I think we want something quick that we can improve to best-practices later.

Regarding EXTENDS versus INCLUDE, this makes me think that we ought to think carefully about the design of our front pages, at least; but can take a least-effort approach to converting some of these small snippets.

A: 

You might be on a hiding to nothing - it'll certainly depend a lot on the details, e.g. your use of third-party libraries and custom JSP tags. Do you just want to implement it in Django with minimal work, or do you want the finished site to reflect Django best practices? For example, in Django it's common practice to design templates using their extends feature - although Django does have an include tag which is analogous to <jsp:include/>, one sees extends more often and include much less often. In the JSP world, the extends functionality is not part of vanilla JSP and is implemented using third-party libraries e.g. SiteMesh or Tiles.

If I were faced with the task of "get something that works - fast!", my first approach would be to work up a Python script which parsed all the JSP files (using a fairly unsophisticated parser based on regular expressions) and spat out the equivalent Django template files, flagging up the hard stuff as it goes. It probably won't be pretty and it won't do everything well, but it'll be systematic and you'll get a checklist to things which need to be done by hand (e.g. template tags which need to be implemented). The likelihood of this approach adding value is proportional to how tidy and systematic the JSP code is, whether you use scriptlets at all, and so on.

Vinay Sajip
Thanks for your ideas - I'll edit the question to respond to some of this.
Vicki Laidler