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 978037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:00:01+00:00 2026-05-16T04:00:01+00:00

Should I declare an attribute in a javabean that holds a date value a

  • 0

Should I declare an attribute in a javabean that holds a date value a user types in on an HTML form as a String or Date?

I feel I should declare as a Date, however, since I do server validation on all form data, if the date doesn’t validate, when I pass the form bean back to the jsp view for correcting, I lose the date value that the user tried to type in.

If I declare as a String, if the date doesn’t validate, I’m able to set the string value in the bean and pass the bean back to the view and the user can see what they incorrectly typed.

But with a String declaration for Date inputs I forsee problems down the road with my DAO. I want to be able to use a DAO utility which generates a prepare statement using setObject.

In my html form I request dates to be mm/dd/yyyy and in DAO i’m using Oracle Date. I can not use hibernate or such, since this is a corporate intranet.

What is the best practice “pattern” I should be following??

  • 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-05-16T04:00:01+00:00Added an answer on May 16, 2026 at 4:00 am

    Just store it as Date in the model. You can make use of conditional operator in EL to display the submitted value instead of the model value whenever the model value is absent.

    <input name="date" value="${empty bean.date ? fn:escapeXml(param.date) : bean.date}" />
    

    The JSTL fn:escapeXml() is just there to avoid XSS attacks.

    To get a step further, you could add an extra layer with a Map<String, Object> params which contains either the submitted value or the final/validated value depending on the validation outcome.

    <input name="date" value="${fn:escapeXml(bean.params.date)}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I guess the procedure should be something like this: declare @db varchar(100) declare @user
I feel like this is something that Google should be able to solve for
Should we declare the private fields as volatile if the instanced are used in
Should all structs and classes be declared in the header file? If I declare
Should I constantly have a session open in my web site with user accounts,
I declare my GLSL ES shader program within a HTML file, using this code:
There is a constructor of lucene Field: Field(String name, String value, Store store, Index
How would I declare a semantic action that calls a free function that doesn't
In a DTD file, how do I declare that an element must have an
I am trying to dynamically create an inline PDF that, when the user chooses

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.