Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

posting characters to a servlet

 
Jason Kwok
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21137
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic