• Post Reply Bookmark Topic Watch Topic
  • New Topic

enums in JSP  RSS feed

 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have the next code:






Till here I get a white screen.


When I print select[] using:




I get this error:


Looks like the values from the enum, are not reaching the view.

Any idea, please?

Regards, Isaac


 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You set an attribute on the request, but then try and retrieve it as a parameter.

Parameters come from the client.
You should be getting your array using getAttribute.

In any case, you don't need the Java scriptlet thing.  You can get that data directly in the tag:


Also, this will be an array of Articles, so 'entry' will be an Article (it should really be singular).

As a note, your enum shouldn't have setters.  Are you really planning on changing the attributes of each enum?
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I try to do it like this:



I get this error:

 
Tim Moores
Saloon Keeper
Posts: 3896
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"enum" is a Java keyword, and thus not a particularly good choice for a variable name; try something else.
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. I changed it into:



And not error is there.

Now in the .jsp I try to list all the articles from the enum.



In the web.xml



All looks fine to me, but I get:



Any idea, please?
 
Tim Moores
Saloon Keeper
Posts: 3896
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where in the classpath is that class?
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this package in the resources:

 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the URL

 
Tim Moores
Saloon Keeper
Posts: 3896
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this package in the resources:



Not sure what you mean by "resources", but what I meant is: in which file in the classpath does that class exist? It seems that it is not actually anywhere in the classpath, so make sure it is where you think it is.
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By classpath of the file do you mean:


Else how couldI check the classpath of that single file?
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where has that class been deployed on your Tomcat server?

Normally it will be either in a jar file in the <yourapp>/WEB-INF/lib directory, or directly in the <yourapp>/WEB-INF/classes directory.
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the WEB-INF,  there is only the web.xml. In the Tomcat folder it doesnt appears there...
 
Dave Tolls
Rancher
Posts: 2914
36
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you deploy to Tomcat (inside the webapps folder) you should have:


If all your code is in jar files then you could drop the classes folder, and similarly if you have no dependent jar files you could drop the lib directory.

It sounds like you aren't actually deploying any code.
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Maven, looks like there was something weird there. It was solve creating a new web app in Netbeans and importing the files
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Going back to the point of the post.

I have a view in .jsp with this code:



web.xml





The values of the enum, doesnt appear in the view, neither an error.

Any idea, please?
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have this enum:



Now I make a loop to show them



All works but the first element doesnt appears

Any idea, please?

 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the ptoblem is here:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think. What does art.getValue() return?
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It returns a String, what should I think there? It works


When the choice in the view matchs a value in the Enum
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It returns the position one, when I look up for a method like getIndex(0), I dont find it.

So ... how could I get the position 0?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!