File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes posting characters to a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "posting characters to a servlet" Watch "posting characters to a servlet" New topic
Author

posting characters to a servlet

Jason Kwok
Ranch Hand

Joined: Mar 31, 2005
Posts: 126
Hi,

Hopefully this is a simple problem. I have a jsp page with a form that is used to allow users to post info. Example, a customer can update their personal account details through this form.

My problem is that when a user enters characters like ' " * < > - , etc... those characters either don't get included in the post or a servlet error occurs. If I post the exact same info without any special characters as mentioned above, it works just fine.

The input is taken inside input text boxes and retrieved in the servlet as a string. Should I be doing something different?

Thanks,
Jason
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18649
    
    8

If you want a different result, then yes, you should be doing something different. However it's hard to suggest what you should be doing instead, when we don't know anything about what you are doing now. Except that you have a string in your servlet.

Is your form just a plain form, or is there some Javascript involved? And what, exactly, are you doing with that string in your servlet?
Jason Kwok
Ranch Hand

Joined: Mar 31, 2005
Posts: 126
Yes it's just a simple form with no javascript, as I don't feel a need for it for any validation purposes or anything otherwise. The form data is posted and all items in this case are assigned to strings in the servlet.

From that point, those strings are added to a bean and then sent to be added to my database through a model. I add them to a bean simply because the form carries related data, so storing them all in a bean keeps those related data items together and easy to transport to my model.

I'd appreciate any advice you can offer Paul!!

Thanks,
Jason
Jason Kwok
Ranch Hand

Joined: Mar 31, 2005
Posts: 126
Ok, maybe I'll phrase this a little better... I have a simple form, for simplicity we'll say just one input text box taking in search criteria.

If I enter in any character string like "java" or "moose", then I will get results. But if I include any characters that aren't numeric or appear in the alphabet, then I get an error. Ex. "can't", "dark*r", "yell!!"

I post the search criteria directly to a servlet and assign the parameter to a string. Should I be assigning it to another data type to resolve this conflict? Or is there something else I'm overlooking?

Any help would be greatly appreciated!!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Have you looked in your server's logs to see if you can get a stack trace?
Once you get a line number, it should be easy to figure out where the problem is.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: posting characters to a servlet