How to solve The JSP specification requires that an attribute name is preceded by whitespace ERROR?


tomcat

Today when i deployed my application in Tomcat 7 ,and click on home link , I got this error message.

org.apache.jasper.JasperException: /home.jsp(65,92) The JSP specification requires that an attribute name is preceded by whitespace.

But when i run my application  in  Tomcat 6 it runs fine. The problem is due to no whitespace between attributes of a link (<a></a>) tag. Here is the code:
 <a style="cursor: pointer" >
<img src="images/rating/like.png" name="upCount" alt="Like"onclick=doArticleRating("2")>
</a>

There is  no space between alt="Like" and onclick=doArticleRating("2").

Above code runs fine in Tomcat 6 but when you run the same code in Tomcat 7 it give error.

So if you want that above code will run fine in Tomcat 7 then  put space between  alt="Like" and onclick=doArticleRating("2"). Following code will run fine in both Tomcat 6 and Tomcat 7.
 <a style="cursor: pointer" >
<img src="images/rating/like.png" name="upCount" alt="Like" onclick=doArticleRating("2")>
</a>

Conclusion:- Put space between attributes of  HTML tags , Custom Tags of any framework and JSP tags etc to run your application in Tomcat 7.

Thanking you for  reading  this Tutorial  .Please leave your comment regarding this Tutorial.

 

Share on Google Plus

About JK STACK

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

11 comments:

  1. Welcome dude............my pleasure..

    ReplyDelete
  2. thank you for supportive text.

    ReplyDelete
  3. Very Helpfull. it worked.

    Thanks a lot!!!

    ReplyDelete
  4. grep --include=\*.jsp -r '.*["][a-zA-Z]*[=]["].*' . >/tmp/jsp.txt to find all possible Files when porting an old huge project....

    ReplyDelete
  5. add this to the catalina.properties
    org.apache.jasper.compiler.Parser.STRICT_WHITESPACE=false
    restart and retest

    ReplyDelete
  6. The error message "The JSP specification requires that an attribute name is preceded by whitespace" typically occurs when you're working with JavaServer Pages (JSP) and you have an issue with the syntax of your JSP code. This error can be caused by various issues in your JSP code, such as missing whitespace characters, incorrect tag placement, or improper syntax. Here are some steps to help you solve this error:

    Check Your JSP Syntax:

    Carefully review your JSP code to ensure that it follows the correct syntax rules. Pay special attention to tag attributes and their formatting.
    Look for Missing Whitespace:

    As the error message suggests, make sure that there is whitespace (e.g., a space or tab) between the attribute name and its value in JSP tags. For example, should have a space before page.
    Validate Tag Placement:

    Ensure that JSP tags are placed correctly within your JSP document. Tags should be well-formed and properly nested.
    Escape Special Characters:

    If you're including values with special characters in your JSP attributes, make sure they are properly escaped or enclosed in quotes.
    Use Valid JSP Elements:

    Verify that you're using valid JSP elements and attributes according to the JSP specification. Out-of-date or deprecated elements may lead to errors.
    Check for Typos and Case Sensitivity:

    Double-check that attribute names are spelled correctly and that you're using the correct case (JSP is case-sensitive).
    Inspect the Affected Line:

    Examine the line in your JSP code where the error is reported. This can help you pinpoint the exact issue.
    Refer to Documentation:

    If you're uncertain about the correct usage of a particular JSP tag or attribute, consult the official JSP documentation or resources specific to the JSP framework you're using.
    Test Incrementally:

    Make small, incremental changes to your code and test it after each change to identify when the error is resolved. This can help isolate the problem.
    Use an IDE or Code Editor:

    Using an Integrated Development Environment (IDE) or a code editor with JSP syntax highlighting can help you spot syntax errors more easily.
    Consider Framework-Specific Issues:

    If you're using a Java web framework (e.g., Spring MVC, Apache Struts), be aware that the framework may have its own conventions and requirements for JSP tags and attributes.
    Check for Special Characters in Attribute Values:

    If you have attribute values that contain special characters (e.g., "<", ">", "&"), make sure they are properly escaped using HTML entities or CDATA sections.

    Regards: Cracksjet

    ReplyDelete
  7. Contact EasyJet customer service at +44 (0) 330 5515151 or 18888006966 and request assistance regarding bookings, baggage, refunds, etc.

    ReplyDelete