• Post Reply Bookmark Topic Watch Topic
  • New Topic

illegal start of expression  RSS feed

 
Nilesh Patel
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got illegal starrt of expression

when i decalare any variable as private or public in JSP , Why???

likes..

<%
public int count =0;
%>

or


<%
private int count =0;
%>
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because any code in your scriptlet tags <%....%> goes into the service method of the generated Servlet. Which in turn would mean, variables declared inside the scriptlet tags are local to the service methods. And you cannot use the 'public' access modifier on a local variable, can you?

ram.
 
Sujittt Tripathyrr
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like java functions with in the method u can't put any access modifiers.so here what ever u wrote in the scriptlet that will go to _jspservice so it will not allow u to declare you any access modifiers.

Thanks

Sujit
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sujittt Tripathyrr,

JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

thanks,
bear
JavaRanch Sheriff
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!