File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with multiple variable declaration

 
Michael Jameston
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a jsp that lets a user pick a favorite technology and then displays the results. The problem is that my declarations keep overwriting the other variables so if you select the third option the first time then the results are correct, however if you choose option one the next time then option 3 goes to 0 and option 1 becomes 1. What could be causing this as I thought the init() method only ran once and initialized these variables.

 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This code is working fine....
 
Michael Jameston
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it is just my version of netbeans. I will upload it to another server and give it a try.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
netbeans also using Tomcat i think...
I tried on tomcat 5.5.28
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't ask, but just so you know, that JSP struck me as a very odd combination of scriptlet and JSP.

While there's (almost) never any good reason to use scriptlet code in JSP, if you *are* going to use it, it would at the very least make sense to use it appropriately.

Why put some Java code in JSP tags (the variable declarations) and other in scriptlets--doing Java is what scritplets are for? Why generate HTML in scriptlets--doing HTML is what non-scriptlet JSP is for?

Edit: Oh, right; I forgot that <jsp:declaration> creates instance variables. That makes the code even worse, although at least I understand why it's there now. My fault--seriously, I've written exactly one line of scriptlet code in the last five years--can't blame me for forgetting. (Yes, you can; I should have remembered that one.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic