File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Newbie JSP question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Newbie JSP question" Watch "Newbie JSP question" New topic
Author

Newbie JSP question

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

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

Joined: Jan 10, 2002
Posts: 61092
    
  66

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

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

Joined: Jan 01, 2006
Posts: 74
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

Joined: Jan 10, 2002
Posts: 61092
    
  66

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

Joined: Feb 08, 2004
Posts: 1281
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


java amateur
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

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

Joined: Apr 28, 2006
Posts: 55
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

Joined: Jan 10, 2002
Posts: 61092
    
  66

Since this has definitely become Eclipse-focused, I've moved it to the IDEs forum.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Newbie JSP question