File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How to read + operator using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to read + operator using javascript" Watch "How to read + operator using javascript" New topic
Author

How to read + operator using javascript

Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
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

Joined: Aug 18, 2009
Posts: 174

Thats because you're submitting unescaped value to the server. So server thinks you're submitted test space test.
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Hi Zandis,

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

Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

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

Joined: Dec 21, 2006
Posts: 197
we are using spring MVC framework and json, code looks like this
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

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

Joined: Dec 21, 2006
Posts: 197
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

Joined: Dec 21, 2006
Posts: 197
Zandis,

i got solution, I used encodeURIComponent() to send strign values to server getting correct value.
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

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

Joined: Dec 21, 2006
Posts: 197
ok, i will wait.
let me know if you find anything (I am also checking)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to read + operator using javascript
 
Similar Threads
Oracle Sequence and JDBC
Accessing private variables in equals()
How do I get an int in JSP using struts ???
pre and postfix operator in for loop
working of Install_Notify