Hi, I am very ( I mean very ) new to J2EE and web development. I have been working with J2SE for years now and I understand Java very well.
That being said, I have recently taken over a project that was being worked on by a co-worker who recently left the company. The project is running on Tomcat 5.5 and using Java 1.5 with AJAX, Hibernate, Struts and Tiles.
What I am trying to fix is a section of code where there is a page with a box for comments that the user of the web site can place whatever they want into. Sometimes they would like to place a + or % symbol in the comment box.
However, when they do so the symbols are not showing up on the other side. The reason is, they are using a POST command like a GET command and placing everything in the URL (yes all of the comment data is a key / value pair at the end of the URL).
Now, I am no web guru, but I do know that besides having character issues (reserved chars), there is that little limitation of 1024 characters...
I have tried to place a key/value pair in the request.send("key=value") field to no avail. When I go into the execute method on the other end and try to retrieve the value based off of the key I get null.
Can somebody recommend a fix for this, or something I can read that would give me a clue? I have been pouring over AJAX web pages and have found lots of suggestions, but none have worked thus far.
If I am understanding your problem correctly, you can't get certain symbols (+, %, etc.) to send properly. To fix this, you must encodeURI to encode those symbols into their url equivalents.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Thank you for the prompt response. I am using the encodeURL before I make my call to getDataDiv. There are two problems with this:
1.) It works for all symbols except for the + symbol, which it considers a space. It does not place the + with %2b it thinks it is a space. Therefore, on the other end it shows up at a space and not a + symbol.
2.) The user can only enter comments in that are less than 1024 characters.
PeejAvery you're great!! encodeURI wasn't the fix, but the link you provided was lol. The encodeURIComponent was exactly what I needed.
Thank you.
Well, that solves one problem... Now they can add the + into their comments. However, what would you recommend I do about the 1024 limit imposed in using the URI to pass data?
Bookmarks