Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about an old Thread (was: how to fix "unchecked" warnings in JSP pages)  RSS feed

 
David Johnsonz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a legacy site which uses JSTL and Struts 1 tags. I have jsp pages with jsp tags in the form:

<%@ include page="/something.inc" %>

When I start to compile this site against Java 5/6, I get the following error message:

[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

I found a poster on your site from back in 2007 who was experiencing this exact same problem. Unfortunately, the best answer back in 2007 was to ignore the warnings. My webapp has thousands of these warnings and I would really like to find a better resolution.

For reference, here is the thread from 2007:
http://www.coderanch.com/t/462333/JSP/java/fix-unchecked-warnings-JSP-pages

Does anyone have any new/better ideas about how to resolve the unchecked warnings when using taglibs in JSP pages on java 5/6? Thanks!
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37261
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that is still the best way to deal with it. Legacy code has scriptlets unless you can refactor it and the warnings are valid.
 
David Johnsonz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Legacy code has scriptlets unless you can refactor it and the warnings are valid.

Actually the problem in that old thread (and this one as well) was JSP tags which perform unchecked operations. From my understanding, a scriplet is java code directly in the JSP page. A JSP tag is something like <jsp:include>. If the problem was in a scriplet, I could easily edit the scriplet to correct the unchecked operation. Since the problem is in a tag, I would need to obtain the source code of the taglib and make changes to it. So in summary, the problem is not related to scriplets but JSP tags.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is being included by the JSP include tags? JSP files containing scriptlets perhaps?
 
David Johnsonz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:What is being included by the JSP include tags? JSP files containing scriptlets perhaps?

The JSP file being included does not have any scriplets. The included JSP tag contains a long list of JSP includes. Here is small excerpt:


When I run the compile with Xlint:unchecked, the error is from the include tag itself and not the content being included. Here is the more detailed warning:

warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
[javac] _jspx_dependants.add("something.inc");

The only reference to "something.inc" is the name of the file being included. The phrase "something.inc" does not appear anywhere in the file named "something.inc". The poster from the previous thread in 2009 actually pulled up the source code for the offending tag and found the following:

 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the error/warning is coming from the java code generated from the tags.

How are you "compiling" this code? Is it precompiling your JSPs?
I don't know any way to avoid this issue, except by ignoring those errors.

Maybe you can upgrade the servlet container? What are you using right now?
A newer container may generate code that doesn't generate compile warnings...


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!