Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbie JSP question

 
Melinda Savoy
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Stu Higgs
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this has definitely become Eclipse-focused, I've moved it to the IDEs forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic