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 avoiding '#' '+' '%' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "avoiding Watch "avoiding New topic
Author

avoiding '#' '+' '%'

Manoj John
Ranch Hand

Joined: May 13, 2004
Posts: 36
hi
In my application i am encrypting message using javax.crypto. and sending it through request. it is working fine but problem is whenever thereis an occurence of any one of these symbols '+' '#' '%' in the encrypted message
request.getParameter skipps that symbol and making problem on decryption.
please suggest any method to avoid these symbols.I tried with utf8 and ascii encoding with base64 encoder both give '+' symbols on encryption.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

You should be URL-encoding all parameters, encrypted or not.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Manoj John
Ranch Hand

Joined: May 13, 2004
Posts: 36
thanks Bibeault


But can i make sure that the encoding will remove these unsafe and reserved characters by this code
-------------code--------
URLEncoder.encode("toEncode","UTF8")
--------------------------------
and Decode with
------------------------------------
URLDecoder.decode("toDecode","UTF8")
----------------------------------------
or to use any other like ASCII like something..
am i in right way?
[ July 30, 2004: Message edited by: Manoj John ]
Mike Cronin
Greenhorn

Joined: Apr 17, 2002
Posts: 25
Yep,

import java.net.URLEncoder;

and...

URLEncoder.encode("Your Encrypted String", "UTF-8");

and that's it.


Mike Cronin
[ August 01, 2004: Message edited by: Mike Cronin ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: avoiding '#' '+' '%'