Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read + operator using javascript

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In my jsp page I am reading string description values and storign into database using hibernate, if i enter description 'test+test' I am getting only 'test test' I am not getting + operator(other than + I am getting other operators).

Can any one give me any idea how to get + operator.
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats because you're submitting unescaped value to the server. So server thinks you're submitted test space test.
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Zandis,

So, How to send '+' operator to server, any idea.

 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.

I guess that you're using jQuery framework. If so, you can use $.URLEncode(string) method to escape you'r value.

Actually it would be great if you'd show us how do you post this value to the server.
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we are using spring MVC framework and json, code looks like this
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know much about Spring MVC, but I guess that problem that values is not being escaped is here:
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in alert box i am getting correct descrition value, the same + operator is not coming in java code.
datatype is standard across to application, i don't think so i can change for one screen. Other than changing datatype, any way to send operator.
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zandis,

i got solution, I used encodeURIComponent() to send strign values to server getting correct value.
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if it works, I'm sure that this is not the right solution anyways. Please wait to see if anyone will point you to the right solution in this case.
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i will wait.
let me know if you find anything (I am also checking)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic