• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Passing cent symbol from jsp to servlet -- Problem

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on three standalone tomcat servers --
First on win2000 , the version of tomact is /4.1.18. I am trying to pass cent ( � ) alt+0162 from jsp to servlet but it doesnot pass the cent symbol , it pass some weired symbol which is �. Same application on sun solris , the version of tomact is /4.0.4.,it passes ? instead of cent symbol. Same application on Linux , the version of tomact is /4.0.4.it passes the cent symbol correctly. IS THERE ANY REASON WHY IT IS NOT PASSING THE EXACT RESULT IN THE FIRST AnD SECOND CASE.
Servlet is -- String sProm = req.getParameter("PromotionText");
JSP is --- Promotion Text: <TEXTAREA NAME="PromotionText" ROWS="2" COLS="30" WRAP="VIRTUAL"></TEXTAREA>
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mehta,
are you encoding the url as (I guess) you are passing the symbol through the URL.
Mounika.
 
Mehta Saryu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope ! I am not encoding anything and i am not passing through hidden field also.
I am just reteriving the value throught getParameter("NameofField").
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

are you encoding the url as (I guess) you are passing the symbol through the URL.


Actually from the orginal post (which I will admit is not very clear), I assumed that the offending character was being passed as part of the text area.
If this is the case, no encoding should be necessary since that will happen as part of the form submission. (I'm assuming that there is no funky enctype specified on the form?)
bear
[ April 02, 2003: Message edited by: Bear Bibeault ]
 
Mehta Saryu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope !
I didnot specify any encryption of anykind . the text area is in form post method.
is jsp .
< form name ="" method="post" >
<textarea name="promtext"> </textarea>
getparameter (promtext) in servlet.
this is very simple form .
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is just a guess, but is it possible that the Java default Locale is different on each of the three platforms that you tested? Someting like this would cause a given unicode character to display differently on different systems.
Mark
 
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
just an attempt...define the charset for your
html..
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
cb
 
Mehta Saryu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nope !
it didnot work
 
Mehta Saryu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any other idea will be highly appreciated.
thanks
Saryu
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oooh,
mounika mentioned URLEncoder yet. Try sending your ¢ encoded with it ( even you have POST-method ):
java.net.URLEncoder.encode( ¢String )
and decode with:
java.net.URLEncoder.decode( ¢String )
HTH cb
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forgot something:
since jdk1.4 you can specify the charset:

URLEncoder.encode( string, "UTF-8" )
or just use &cent;
cb
[ April 03, 2003: Message edited by: Christian Baron ]
 
Mehta Saryu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
how do i do this.
<TR>
<TD COLSPAN=4><TEXTAREA NAME="PromotionText" ROWS="3" COLS="40" WRAP="VIRTUAL"></TEXTAREA></TD>
</TR>
above is the text area in my jsp do I have to write the textarea value= java.lang.String encodeURL(theurlvalue) ?
how do I know what value entered in text area since it is in html and I need that string value to be in java to pass into method.
The value of the texarea will be like this.
"Testing the cent symbol � .Please share your creative ideas to solve this."
 
Mehta Saryu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Code snippet will be higly appreciated.
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
my idea was:
if it is encoded in POST automatically...
...maybe URLDecoder.decode() will display your ¢

This one encodes the textfiled-value with JavaScript before submit.
If this also doesn't work i tend to Marks Opinion

good night
p.s.: if you have don't have jdk1.4 use it without ,"UTF-8"
good night
cb
[ April 03, 2003: Message edited by: Christian Baron ]
 
Mehta Saryu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to get the cent symbol in the servlet from jsp .NOW NEW PROBLEM !!
I am using postgres as database.
When I am updating the databse
update set promotiontext=”sss � cent symbol insert” from the sql it is inserting cent symbol the database but the same query through my application ( I have debugger on to view query) inserts ? instead of cent symbol .the debugger shows me the same query when my applciaiton runs .

Any idea ??
 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also running into this problem, but it is a lot bigger concern for me, since it happens... for file transfers. I uploaded a test file from the jsp to the servlet, and I found that the following bytes get replaced by '?':
0x81
0x8D
0x8F
0x90
0x9D
Just informational for now, I will try the fixes posted here and see if that solves the problem.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic