• Post Reply Bookmark Topic Watch Topic
  • New Topic

Syntax error on token, Identifier expected  RSS feed

 
casey Gould
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new to Java/JSP so bare with me.

I'm converting ASP code to Java, but I'm getting a syntax error (line 50 in the code), I'm not sure if I have declared the variable or string in the correct place.

any suggestions would be great that you

 
Knute Snortum
Sheriff
Posts: 4276
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
con_currency_sdo seems to be declared as just an Object. Errors is not a property of Object.
 
Robert D. Smith
Ranch Hand
Posts: 221
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On line 46 you set objError = : But objError isn't declared anywhere. (that I could see anyway. doesn't necessarily mean it's not there).

Another issue I see is that you seem to declared the majority of your variables, methods and classes as final. For example, on line 45 you declare a 'final String strNoCurrencyMessage = "";' What this does is declare an empty string that you cannot ever change. According to the JavaDocs you can only assign a value to a final variable once. Similar rules apply to methods and classes. Final methods can not be extended. All sorts of fun stuff.

And while it's not a big thing to me, but the Hungarian notation usage is a no-no.

Regards,
Robert
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a no-no for me is doing all this in a JSP.

I know you're translating an ASP, but moving from one language/framework to another is not simply a case of changing a bit of syntax.
A Java web app is supposed to have its processing side of things done via a Servlet, with a JSP as a tool for laying out the response.
 
casey Gould
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Dave, yeah I have set everything up in eclipse. I've created the servlet (I think) I have a folder called WebContent where my JSP files are. Then I have java resources where my DB connection is (have tested and can pull data from the DB). I have the connection in the JSP file as well, since a lot of examples I've seen have the Java/jsp code above the <Doc type>

Am I wrong in doing it this way?

@Robert, yeah that's the only place I have the objError declared, Should I declare at the top where I'm declaring the other variables? I made everything "final" because I know that it should change in color, when I had it as just a "string" it was just plain text. Did this to see if I could get past errors and keep debugging.
 
Robert D. Smith
Ranch Hand
Posts: 221
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the problem -- objError is not declared. You are assigning an empty string to something that is not defined, and the compiler doesn't know what to do with it. What is objError ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
casey Gould wrote:
Am I wrong in doing it this way?

Yes -- modern JSPs should contain no Java code. That's an old holdover from JSP 1 which was superseded by JSP 2 in 2002 -- 12 years ago!

I recommned novices to servlets and JSP read
  • The Secret Life of JSPs
  • The Front Man

  • The first makes sure you understand what JSP is all about (similar, but not identical, to ASP), and the second how to properly structure modern Java web apps.
     
    casey Gould
    Greenhorn
    Posts: 17
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you for help everyone, I believe I have gotten passed it.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!