user7392562
user7392562

Reputation:

Find JSPs with incorrect syntax

I have old application which was working fine till now in java 1.7 (tomcat 6). After upgrade to java 1.8 and Tomcat 9, we see lot of run time errors in the applications because of way JSPs are coded

e.g., onkeypress attribute is added twice to the textfield, 
nospace between two attributes (onchange="limitText(this,500);"tabindex="6"), etc.

Are you guys aware of any tools that can identify such JSPs so that we can fix these issue. If not do you have some suggestion on what shall I do? I do not want to search for these issues manually as there are thousands of JSPs.

Upvotes: 1

Views: 737

Answers (2)

VHS
VHS

Reputation: 10184

You have two options:

Option 1: Perform regex based find and replace operation on all of your JSPs through a text editing software like Notepad++ or Textpad. E.g. you can search for a pattern of [a-zA-Z]\"[a-zA-Z] and then examine the results. If the results are correct, perform a find and replace.

Option 2: Suppress the JSP parser error in Tomcat. I think it is Tomcat specific error. See this Tomcat 9 docs.

Add the following line in the catalina.properties file located at "APACHE_TOMCAT_HOME\conf":

org.apache.jasper.compiler.Parser.STRICT_WHITESPACE=false

Restart the application server.

====

I think you should go with the option 2 as there is no real harm in it and also it saves a ton of developers' time.

Upvotes: 2

Aravind
Aravind

Reputation: 1255

This can help you to format basic issues ub the JSP page.

From eclipse Window Menu, choose Preferences

From the Preferences Window choose Web => HTML Files => Editor

From the Inline Elements: view, add all tags that you want appear in one line

Now whenever you press CTRL+SHIFT+F, the JSP will be formatted to your new style

Upvotes: 0

Related Questions