JSP Indentation and Formatting

I'm trying out Idea (v3.0) and since we do web applications I consider JSP editing to be an important part of my IDE.

But I'm amazed at how badly Idea is formatting the page (aside from the java scriptlets, which I rarely use). The auto-indentation rules seem non-sensical. I could maintain the indentation manually, but I generally expect my IDE to do that.

Am I doing something wrong? Is there some setting I don't have turned on?

I'm not asking for anything really fancy. It seems that all you would really need to do is apply the XML indentation rules with a few exceptions for the special JSP tags (and to hell with those people who don't use XHTML).

If you work with JSP files, what do you do?

0
12 comments

William.. I am also in the same boat as u are.
Guess what I do, I type my code in IDEA, and when I want formating, I copy
my code to XMLSpy (they have a jsp editor) and have it formatted, and then I
copy back my code to IDEA. It is sort of crude way, but what to do.

Saumendra

I'm trying out Idea (v3.0) and since we do web applications I consider JSP

editing to be an important part of my IDE.
>

But I'm amazed at how badly Idea is formatting the page (aside from the

java scriptlets, which I rarely use). The auto-indentation rules seem
non-sensical. I could maintain the indentation manually, but I generally
expect my IDE to do that.
>

Am I doing something wrong? Is there some setting I don't have turned on?

>

I'm not asking for anything really fancy. It seems that all you would

really need to do is apply the XML indentation rules with a few exceptions
for the special JSP tags (and to hell with those people who don't use
XHTML).
>

If you work with JSP files, what do you do?



0

Why don't you simply submit requests in the Tracker for the cases when it
works bad?

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"William Tomlinson" <jiveadmin@jetbrains.com> wrote in message
news:6226169.1038408969116.JavaMail.jrun@is.intellij.net...

I'm trying out Idea (v3.0) and since we do web applications I consider JSP

editing to be an important part of my IDE.
>

But I'm amazed at how badly Idea is formatting the page (aside from the

java scriptlets, which I rarely use). The auto-indentation rules seem
non-sensical. I could maintain the indentation manually, but I generally
expect my IDE to do that.
>

Am I doing something wrong? Is there some setting I don't have turned on?

>

I'm not asking for anything really fancy. It seems that all you would

really need to do is apply the XML indentation rules with a few exceptions
for the special JSP tags (and to hell with those people who don't use
XHTML).
>

If you work with JSP files, what do you do?



-1

Why doesn't the original poster just submit a bug?


Since I'm a new user to Idea, I thought that maybe I might simply be using the product incorrectly. So I wanted to check with the forum community to see if JSP indentation and formatting did actually work and I was just doing something wrong.

If this is a known problem with the product, I was also curious to know what other users were doing to work around.

But, if the forum confirms that this is a known problem, then I will submit a bug to tracker. (But unforunately, I won't be able to use the product, as this would be a show stopping bug for me.)

0

The problem is not indenting the actual JSP code between the <% %>, that's done correctly since it's the same as the java intentation engine there, I think what you're seeing is that the indentation is not matching the surrounding HTML like you would expect it to. This is a feature request that has already been submitted to tracker.

R

0

What kind of formatting does XMLSpy do? Just the Java code or the
whole file, i.e. HTML plus Java code? And how do you do this in
XMLSpy? I downloaded the version 5 demo just for checking out this
feature but it seems XMLSpy does not like my JSPs at all. I wonder
where the JSP integration in XMLSpy is at all since the "new file"
button does not offer JSP file creation. What am I missing?

Michael

On Wed, 27 Nov 2002 10:13:18 -0500, "Saumendra Poddar"
<greencap@hotmail.com> wrote:

>William.. I am also in the same boat as u are.
>Guess what I do, I type my code in IDEA, and when I want formating, I copy
>my code to XMLSpy (they have a jsp editor) and have it formatted, and then I
>copy back my code to IDEA. It is sort of crude way, but what to do.
>
>Saumendra
>
>> I'm trying out Idea (v3.0) and since we do web applications I consider JSP
>editing to be an important part of my IDE.
>>
>> But I'm amazed at how badly Idea is formatting the page (aside from the
>java scriptlets, which I rarely use). The auto-indentation rules seem
>non-sensical. I could maintain the indentation manually, but I generally
>expect my IDE to do that.
>>
>> Am I doing something wrong? Is there some setting I don't have turned on?
>>
>> I'm not asking for anything really fancy. It seems that all you would
>really need to do is apply the XML indentation rules with a few exceptions
>for the special JSP tags (and to hell with those people who don't use
>XHTML).
>>
>> If you work with JSP files, what do you do?
>

0

I don't think this is quite what I'm talking about. Let's take an example.

If I open a new file called test.xml and type:

Lorem ipsum dolor sit amet. I will get auto-indentation (and code folding on the tags, and the scope indicator, and ending tag completion). But if I open a new file called test.jsp and type:

Lorem ipsum dolor sit amet.

I don't get auto-indentation (or code folding, or scope, or ending tags). What I'm proposing is that the non-java (outside <% %>) parts of JSP files should basically be treated as XML files and should get all the features that XML files get in Idea. Inside <%%>]]>'s, the Java indentation engine should take over, of course.

If this is already in the tracker, I apologise. I did search on every variation I could think of.

0

If this is already in the tracker


Looks like http://www.intellij.net/tracker/idea/viewSCR?publicId=3010

files should basically be treated as XML files


I foresee so many requests that "I don't want to close ]]> tags...".

--
Best regards,
Mike Aizatsky.
-


JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


0

I agree with Mike, what ever you do DO NOT treat HTML like XML unless you're using XHTML. PLEASE!

Here is what I think proper indentation looks like:

<% if(something is true) { %> show me <% } %> ]]>

My point is, treat the HTML indentation like you would if this was a java documentation.

0

Nice english, make that java document, not documentation.

0

Granted, an code formatter that understood the lax HTML accepted by all the major browsers would be nice. But I'm guessing that that would take a long time to develop. My suggestion to just treat JSP files as XML was an attempt go for a "good enough" solution while reducing development time (assuming, of course, that the XML formatting engine code could be adapted).

The other suggestion in the thread that the formatter should understand the relationships between the java and non-java parts of JSP files is a good one as well. But again, would take a long time to develop.

My hope here was to find an 80/20 solution. That is, cover 80% of the problem with 20% of the effort, by treating the non-java parts of JSP files as well-formed XML (And then refine it from there, if there is enough demand).

0


What do the IntelliJ staff use to edit the company web site?

This thread made me wonder what the IntelliJ staff use to edit the JSP pages on the company web site? Do they use the JSP mode of Idea? If so, do they just not worry about formatting? Any employee care to comment?

0

Look at the source. Looks like someone is just winging it. The tabbing is not exact on the HTML, so someone got lost while making the long index.html page.

Folks, every html editor out there does proper formating of HTML. Now IDEA is NOT an HTML editor, but it should well be since HTML is such an important part of JSP development. Besides the fact that it should properly indent HTML, it should have code completion for it too.

Being on a Mac, I try to use Dreamweaver MX, but the stupid thing will not format JSP and HTML properly when they're together on the same page. I don't know of an IDE out there that is good at doing that. CodeGuide doesn't do it either. So I think that the time IDEA will spend making this support complete is well worth it. it's obvious there is enough demand for this, let them decide how much of it they want to implement.

Note that lack of support for this feature won't make me stop using IDEA... I'll just develop with pleasure... most of the time :)

R

0

Please sign in to leave a comment.