>>> Paul Kinnucan <[EMAIL PROTECTED]> 09-Jan-01 7:14:52 PM >>>
>>Is it possible to get jde to treat jsp files as it would
>>a java file?
>Hi Gareth,
>I am the primary maintainer of the JDE and so am
>theoretically the person in the best position to estimate
>the feasability of what you ask. Unfortunately, I have
>only the barest idea of what jsp is and have never
>seen a jsp file. Perhaps if you provided me with a brief
>intro to jsp and an example of a jsp file, I might be able
>to a somewhat informed opinion.
Paul and Gareth:
I have spent some time thinking about this. I believe it's not really
possible.
The reason is that the JDE is a programmers editor; it's there to
provide:
1. decent editing facilities for displaying and moving around a Java
file
2. in-editor compilation to allow easy fix of compilation time
errors
3. in-editor running and debugging of programs
1. might be possible within a substantially altered JDE
environment... but it wouldn't be easy because JSP syntax is so
radically different from Java.
There is an Emacs mode available that allows editing of JSPs
(html-helper-mode) but it does that by context switching between HTML
code and Java code.
An example of the syntax problem is this small excerpt of JSP code:
<table>
<%
Enumeration en=request.getParameterNames();
while(en.hasMoreElements())
{
String name=(String)en.nextElement();
String value=request.getParameter(name);
%>
<tr>
<td><%= name %></td>
<td><%= value %></td>
</tr>
<% } %>
This except would be used to print in a page the names and values of
all HTTP form parameters passed to the JSP file.
You can see that there are different ways of embedding Java code in
the app. It's extreemly hard even to syntax colour this correctly
(though I believe that *could* be done with some effort).
Points 2 is, at the moment, not possible. This is because there is no
stand alone compiler for JSP code. JSP compilers are fairly simple
things... they simply text translate JSP into a Java Servlet. There
are many JSP translators but they are all contained within servlet
containers meaning that you have to send a request to have the JSP
translated and compiled.
Of course... a stand alone JSP compiler is feasible but none exist
yet.
Problems with point 3 are related to point 2. In order to execute the
JSP you'd need a servlet engine and some way of generating a request.
This might be easier to do than to write a stand-alone compiler; there
are many free-software servlet engines that could be integrated into
the JDE to produce the desired effect.
Sending a request in order to make the JSP go would be harder and
would probably have to still be done through a browser.
Debugging is another issue... there isn't much debugging support in
JSP right now. Sun are working on an annotation system that will, in
theory, allow source level debuggers to be used with JSP but it's not
available in the core specification yet.
In conclusion I think it's a mistake to think about the JDE as a tool
for writing JSP. Writing JSP is better thought of as a multi-tool
effort - cretae the file with an editor, use a servlet container to
test and debug it. Servlet containers have some nice features for
debugging JSPs (such as automatic reloading and recompilation of
changed files) so they're really better suited.
The main thing that we need is a decent syntax colouring mode for
JSP. With html-helper-mode we are someway there but a really good mode
would be substantially different from html-helper-mode. It would also
be a lot of work.
As a final point: Sun and others are working on 4GL tools for
producing JSP... these will be similar to WYSIWYG HTML editors in many
respects but will allow JSP library code (called taglibs) to be
plugged into an HTML like framework. Such tools will probably also
allow bean based JSP pages.
Such tools probably make more sense because JSP developers *tend* to
be non-programmers.
Nic Ferrier