This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes getParameter () method of HttpServletRequest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "getParameter () method of HttpServletRequest" Watch "getParameter () method of HttpServletRequest" New topic
Author

getParameter () method of HttpServletRequest

neelam kamboj
Greenhorn

Joined: Sep 18, 2008
Posts: 5
Hi ,

i am sending a request ( using JAVA code) to servlet as follows:

fldsmsrequest=<Request><ChannelID>IB</ChannelID><UserID>IB001</UserID><Password>lhfkgkniindnncfmnp</Password><ReferenceID>20080918109822</ReferenceID><LanguageID>1</LanguageID><CustomerNumber>111000</CustomerNumber><AccountNumber>111000</AccountNumber><TransactionType>C</TransactionType><SMSTemplateID>1039</SMSTemplateID><SendAsChannel>B</SendAsChannel><MobileNumber> ;971508168069</MobileNumber><EmailID>PoonamK.ext@adcb.com</EmailID><SMSTextValues>18-09-2008 05:31:23|1307494|110|11000</SMSTextValues><EmailTextValues><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"><HTML><HEAD> <TITLE> New ocument </TITLE> <META NAME='Generator' CONTENT='EditPlus'/> <META NAME='Author' CONTENT=''/> <META NAME='Keywords' CONTENT=''/> <META NAME='Description' CONTENT=''/> </HEAD><BODY> <H1> hello </H1> </BODY></HTML></EmailTextValues><EmailTemplateID>0</EmailTemplateID><Filler2></Filler2><Filler3></Filler3><Filler4></Filler4><Filler5></Filler5></Request>



Servlet code is as follows:


but output is seen as


<Request><ChannelID>IB</ChannelID><UserID>IB001</UserID><Password>lhfkgkniindnncfmnp</Password><ReferenceID>20080918109822</ReferenceID><LanguageID>1</LanguageID><CustomerNumber>111000</CustomerNumber><AccountNumber>111000</AccountNumber><TransactionType>C</TransactionType><SMSTemplateID>1039</SMSTemplateID><SendAsChannel>B</SendAsChannel><MobileNumber>971508168069& lt;/MobileNumber><EmailID>PoonamK.ext@adcb.com</EmailID><SMSTextValues>18-09-2008 05:31:23|1307494|110|11000</SMSTextValues><EmailTextValues>


so <EmailTextValues> after this < > is not getting printed.




Please help me out.. as the <EmailTextValues> element contains ("ampersand lt;""ampersand gt;") characters . on this post it is coming as < and >

Thanks in advance.
[ September 18, 2008: Message edited by: neelam kamboj ]

Thank you,
Poonam Kamboj
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63211
    
  69

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63211
    
  69

Are you properly URL encoding the request parameter value?
neelam kamboj
Greenhorn

Joined: Sep 18, 2008
Posts: 5
i have tried using . which doesn't work. Please help me which encoding need to be used.
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
Is the full value actually being transmitted? There are limits to how many characters GET will transmit. Try using POST instead.
Razi Abbas
Greenhorn

Joined: Dec 10, 2006
Posts: 18
I think Ulf has an important point ... when the amount of data that is being passed is big ... use of POST is recommended.

Did you try URLEncoder/Decoder ?
Before you pass a data in url it should be encoded. Once you receive the data in servlet you would need to de-encode it.

- Razi
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63211
    
  69

Originally posted by Razi Abbas:
Once you receive the data in servlet you would need to de-encode it.
No. The call to getParameter() will return the already-decoded value.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: getParameter () method of HttpServletRequest
 
It's not a secret anymore!