• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unclosed character literal?

 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you please tell what is wrong with this String :




In this code



Thanks, your help is appreciated
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this legacy code? If it's new code, you should not be putting Java code -- let alone JDBC code -- into a JSP!
That is a practice that has been discredited for over 8 years now!

In any case, you can't embed scriptlets within scriptlets.

Do yourself a favor and update your JSP knowledge to modern standards.
 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you, I need to do some testing before using my connection in java beans, but what is wrong with this ?

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
majid nakit wrote:thank you, I need to do some testing before using my connection in java beans, but what is wrong with this ?

Aside from the fact that any Java code in a modern JSP is wrong by definition, I already told you:
Bear Bibeault wrote:In any case, you can't embed scriptlets within scriptlets.
 
Paul Clapham
Sheriff
Posts: 21875
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
majid nakit wrote:thank you, I need to do some testing before using my connection in java beans, but what is wrong with this ?

The compiler already told you what's wrong with it. There's an unclosed character literal. I suppose you really meant to ask what that error message meant. Well, a character literal looks like this:

That's how you denote a character in Java. The code you posted contains quotes which don't delimit a single character like that. However maybe you meant those quotes to be actual quote characters instead of delimiters for character literals. If that's the case then you'll have to escape them properly.

But while you're refactoring that code so that it isn't inside a JSP, do yourself another favour and learn about PreparedStatements. They take care of all of the ugly quoting that you are trying to do there, among other things.

You'll find that if you use better practices (e.g. no scriptlets, PreparedStatements, and so on) in your programming then you won't get sucked into this kind of coding swamp.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!