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

  • Home
  • SEARCH
  • 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 8543741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:22:47+00:00 2026-06-11T12:22:47+00:00

initially I was reading some exception knowledge in java.I went through some suggestions such

  • 0

initially I was reading some exception knowledge in java.I went through some suggestions such as don’t use customer exception if there is a already well-defined exception in jdk and dont use customer exception to handle workflow. I agree with these points and they are absolutely right. Now I was thinking of how to handle this scenario. It is quite straightforward. user login.

1 username not exist
2 password wrong

these will be known in DAO layer and I have to populate useful information to the controller layer(ultimately) and let the controller know what was going on and display useful hints in the view.

when I first learning java I was doing like this

these are pseudocode;

   if(usernotexit)
     {throw usernotExistException()}
   if(password_wrong)
     {throw passwordWrongException()}

is this a good practice? if not, how to do it properly ?

  • 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-11T12:22:48+00:00Added an answer on June 11, 2026 at 12:22 pm

    Assuming some code higher up the stack is catching the exceptions and displaying useful information, there’s no problem with this general approach.

    HOWEVER, for security exceptions in this case, it is wise to NOT distinguish between these two conditions in the message to the user. If you tell the user which one is wrong, this information can be used to probe for valid users.

    The response returned to the user for either condition should be “Authentication Failed”. That way you have not given away any useful information (that the user exists, for instance).

    Note that internally you may want to discriminate the cases for logging purposes. Just don’t tell the user which one occurred.

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

Sidebar

Related Questions

I am working on a Java application that will use some Hibernate (annotated by
I have a mainbuf[bufsize] , empty initially. I am reading from some input :
Im reading some RSS from an URL and are experiencing some troubles. Initially I
I'm developing an Android application which involves reading pdf files. Initially on syncing with
I'm having some issues create a connection to (and reading from) a Tibco EMS
I'm reading some text from a local xml file and displaying it in a
I need some mind reading here, since I am trying to do what I
I'm reading someone else's Django code, using PostgreSQL, and this is something I don't
I'm having this exception with some stubs generateds by Axis2: The type org.apache.axiom.om.OMElement cannot
I’m looking at creating a P2P system. During initial research, I’m reading from Peer-to-Peer

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.