• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String in @RequestParam getting truncated? :(

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Java+Spring framework+Tomcat. I'm sending a request to the server using Postman and I've a huge encrypted string data = "L3dRTmJQcjJrMDUzRi9uQ1FmTTlqN09xcEZqbG1YRmdDazRUd0g2Yy9YRmZ0eDh1SFpYZWpJWmZ1ZTE0WnQ4UkVzbmxlbkhaV1BJZDJDNnJ4TmliZFUvL3VvMTNvc2xKSCsyb1JIRzhoZFdOdjMyelY5c29qU3h4NWxKejdWQk1LMVhjK3VoRUtXcmxWWlcrSVZNRFZlYWhFT0Q5cENyRjdacHVBNnpNSVcwPTo66qPpJx%2Bm4htl6rJeNH%2F4Cw%3D%3D" as my @Requestparam argument. On debugging, I observed that the string on the server side is truncated and loses some character. Is it something to do with tomcat server? I require the entire data string so that I can decrypt it back successfully.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that string in the URL (I assume "yes" as you are using RequestParam to map it).
You should not be putting large strings as URL parameters there are various limits to the length of  a URL, often depending on browser.
That could be what you are seeing as it will simply truncate.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:Is that string in the URL (I assume "yes" as you are using RequestParam to map it).


Not necessarily. @RequestParam matches HttpServletRequest.getParameter which is used for both GET and POST parameters.

However, I agree with not using GET for this data. Not only could it cause issues if the string is too large, it also allows anyone to intercept the value. Even with HTTPS, the URL is still visible. If the value is sent in a POST request the value will be a lot harder to intercept. And as a bonus, you shouldn't get any truncation at all.


Akhil, some questions - at what point does your string get truncated? Is it somewhere in the middle, or somewhere at the end? Do you correctly URL encode the entire thing?
 
Akhil Ranjan
Greenhorn
Posts: 17
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Akhil, some questions - at what point does your string get truncated? Is it somewhere in the middle, or somewhere at the end? Do you correctly URL encode the entire thing?



Hi Rob,  

Apology for replying late. My string was not getting truncated at all. It was getting urldecoded when it reached my endpoint. That's why the data at the end of the string was different. If you pass a data string as @Requestparam, it takes care of urldecoding the data by itself. I didn't have to manually do it.
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for sharing the solution
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic