0

Pressing Ctrl+Shift+F on a JSP editor in eclipse only formats the codes within html tags and jsp tags.

But my JSP file has a lots of JavaScript( unformatted) embedded using <script> </script>. So it very difficult to read the JavaScript code.

My Question is:

Is there any plugin or any other way to format those embedded JavaScript along with the HTML/JSP codes to make them readable?

If anyone has already figured out a way to do this, please let me know.

3
  • 1
    It's better to place js code in external files. Not only because of problems with syntax highlighting. Otherwise, you'll get a en.wikipedia.org/wiki/Turducken of code. Commented Feb 8, 2011 at 11:06
  • Actually that type of coding was done by some other people, and now we are maintaining it. its very difficult to read the codes unformatted code. Anyway thanks for suggestion. Commented Oct 13, 2011 at 18:03
  • And thanks for en.wikipedia.org/wiki/Turducken :D. Never heard of it before. Commented Oct 13, 2011 at 18:04

2 Answers 2

2

Well, it seems there is no such way to Format the javascript code mixed into jsp.

Anyway, you can use following simple trick.

  • extract the javascript code into a .js file, format it there and copy the formatted code back to main file.
Sign up to request clarification or add additional context in comments.

Comments

0

First, affirming the important point provided by kirilloid above: avoid JS in HTML/JSP files.

Second, look at the SO discussion Is there a good JSP editor for Eclipse? for further information. Short answer: the Eclipse Web Tools Project (WTP) will format JavaScript in your JSPs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.