Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics on JSP  RSS feed

 
Satyajit Bhadange
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I am facing this problem when i am trying to use generics on jsp
\e.g.

ArrayList<String> al = new ArrayList<String>();

i am getting error something like this:
Unable to compile class

invalid operator blah blah blah.

How can i write generic code in jsp scriplet

i am using jboss and jdk 1.6
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i write generic code in jsp scriplet

Please don't - scriptlets have gone out of fashion a LONG time ago. Properly implement MVC, and use backing beans or servlets for your Java code.
 
Satyajit Bhadange
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But is there any way i can write code containing generic inside scriplet
 
Devaka Cooray
Marshal
Posts: 5554
707
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satyajit Bhadange wrote:But is there any way i can write code containing generic inside scriplet

Is their any reason for you to try to do so?
 
Satyajit Bhadange
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya..

In my application i am usineg model one architecture ...and now i am stuck with a problem hwere i want to add few entries in any data sturcture but i want those entries of only specfic object type...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show the *exact* error message you're getting, and verify that your JSP files are being compiled by the Java version you believe they are.

Then stop writing Java code in JSPs and put it where it belongs--your explanation doesn't explain why you're doing it in JSP, only why you're doing it.
 
Devaka Cooray
Marshal
Posts: 5554
707
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satyajit Bhadange wrote:In my application i am usineg model one architecture.

I'm not sure what "model one architecture" on the earth you are talking about.
However, there are no patterns encouraging you to use java code in your JSPs.
Have a look at this article for a clear explanation of the model 1 pattern.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does "ArrayList al = new ArrayList(); " compile? If so, you aren't on Java 1.6.

Having scriptlets in JSPs is so unmaintainable that whether you use generics or not isn't so important.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!