• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unclosed character literal?

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can you please tell what is wrong with this String :




In this code



Thanks, your help is appreciated
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Yes, my master! Here is the tiny ad you asked for:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic