Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9146273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:42:41+00:00 2026-06-17T10:42:41+00:00

I was wondering … We all know, that we should validate the user input

  • 0

I was wondering …
We all know, that we should validate the user input in the backend, even if we validate it in the frontend. In other words – frontend validation is just for usability, backend validation is for quality and security.

Let’s say I have an input field on my web page and the user can write some text. Is it possible for an attacker to input such a long text, that it would not fit in the variable which holds the text in the backend? What I’ve seen so far is just making sure, that a string would fit in a database field.

String txt = getParameter("usertext");
assert(txt.length() < 201);
// the field in the database: 
// user_text varchar(200),

But if the user text is veeery long, so long that String txt would be too small, wouldn’t my program crash at the first line?

I hope this will not be a discussion on how long a String may be. If we can do it w/o heap sizes and virtual memory it will be great 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:42:42+00:00Added an answer on June 17, 2026 at 10:42 am

    But if the user text is veeery long, so long that String txt would be too small, wouldn’t my program crash at the first line?

    The answer is no: you have no real limit for the String object’s size.

    But take into account the following problem: the UTF-8 characters.

    I had the problem when the database field sizes were expressed in BYTES (instead of chars, this was the default in my case) for the VARCHAR2 type (it’s an example) and you insert UTF-8 characters which take more than one byte.

    Example:

    Database field = VARCHAR2 (50)

    Validation: string length <= 50

    The string €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ has less than 50 chars but more than 50 bytes.

    The spring validation consider it as passed (length is less than 50) but DB insert statement thrown an exception…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wondering if any of you can help me: I've made a signup modal that
Wondering if there is any way to get the lambda expressions that result from
Wondering if anyone can suggest a good file replication tool that will replicate across
wondering if some of you know what javascript framework facebook is using ? Thanks
Wondering if there is a good way to generate temporary URLs that expire in
Wondering if anyone out there might know a trick to a small sql script.
wondering how to carry out this requirement if at all possible. I am modifying
Wondering if there is some preference I can set in excel so that when
Wondering what are the views on this We have a CI server that runs
Wondering if it is ok to have a form inside an HTML email. All

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.