• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Newbie JSP question

 
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working with an old edition of Beginning JSP Web Development and going through its tutorial.

My code:



I am getting a WARNING in eclipse that states:

The local variable myCar is never read

I am running Eclipse 3.2 and Java 1.5.7, and Tomcat 5.

Any insight or direction on how to correct my problem would be appreciated. I did not see a Beginning JSP forum and therefore the reason I amposting here.

Thanks.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problems with the Eclipse parser aren't always really a problem with your JSP. I'd suggest you learn to rely less on an IDE to do your thinking for you and learn what's valid JSP or not.

IDEs are usually pretty poor at analyzing JSP pges.
[ August 12, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I might alos recommend that you get yourself a more up-to-date reference. JSP has changed a lot in recent years and the older ways of doing things have gone by the wayside.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

<jsp:useBean id="myCar" class="com.wrox.cars.CarBean" />

makes a reference variable called myCar to your bean class CarBean

your editor thinks you are not using it or reading it maybe because you are using the JSP getProperty and setProperty which the editor may not understand or interpret as reading or using that reference variable.

If you where to make a reference to the bean class method or member variable in a jsp expression like this <%=myCar.getMake()%> or <%=myCar.make%> the warning from the editor might go away(i'm not sure ). Also, I'm not saying you should do it that way either, because it is best to follow the recommended way of doing things according to the specifications and if that is <JSP:set and <jsp:get then use those, but as Bear said, try to rely less on the editor. I also use eclipse and it becomes a very valuable tool when writing classes as opposed to JSP in my opinion, but once you know JSP good, then you need not worry about those warnings and you might also end up with no java code in your jsp at all where instead you use tags.
[ August 13, 2006: Message edited by: Stu Higgs ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and you might also end up with no java code in your jsp at all where instead you use tags.



Which is one of those "modern way of doing things" that I alluded to, and a good goal to try and achieve.
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but on the other hand you have a right click that has a quick fix and in that case it adds an @Ignore dont know exactly what but eliminates those nasty warnings
 
Melinda Savoy
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

Thanks so much for the time you took in helping to understand what it going on. I did get a NEW JSP book yesterday in hopes that I will be able to better understand WHY some code appears with warnings.

I am truly not trying to rely on the IDE but there was no explanation in the book or the IDE and therefore the reason for my post.

Stu, thanks so much for your explanation. It really helped.

Regards.
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are planning on using Eclipse, you might try using the Eclipse Web Tool Platform. It tends to be pretty good at picking out syntax errors in jsps. Just don't try to use refactoring, it's bad at refactoring jsps.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since this has definitely become Eclipse-focused, I've moved it to the IDEs forum.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic