(newbie) How to return error messages to JSP page.

Hello,
I'm using a very simple Model 1 architecture (no framework such as Struts used.) The webapp just consists of a login.jsp which collects database connection parameters and then activates a servlet to return a PDF report to the browser.
I have a very common need: I would like the errors entered by the user on the login.jsp to be displayed at the top of a new return of the login.jsp (with the bottom of the JSP still providing the edit fields for reentry), errors such as:
1.) User did not enter the username, password, and database name
2.) Having a wrong username/password for the given database.
(2) is more complex than (1), because it would involve feedback from the servlet (which makes the DB connection).
I'm not sure how to code this, however, with just JSP, JSTL and JavaBeans. Does anyone know of an example with source code on the web where something similar to this is done?
Thanks,
Glen

No problem on posting here. Seeing as JSP forum is not accessible, this is the next best choice.
What sort of complexity are you after here?
You can go with the very simple:
Print out the error messages as you discover them.
if (request.getParameter("username") == null){
  // print out the message
  out.println("Please enter your username");
  // or alternatively
  List errors = new ArrayList();
  errors.add("Please enter your username");
}The best way to get feedback is to write your login method to return whether login succeeded or not. That can be a boolean true/false value, or you could return a User object to indicate success, and null to indicate failure.
How much of the code is in servlet, how much in JSP?

Similar Messages

  • How to setup error message in JSP if no data or page found

    I want to show users some error message after user clicks on a link and no page or data is found.
    How do I show users to a valid error message if there is no data exists after they click on a link?

    Add the following line at the top of your jsp
    <%@ page errorPage="error.jsp" %>
    Then, write a error.jsp in whichever fashion u want.
    My error.jsp begins like this
    <%@ page isErrorPage="true" %>
    <html>
    <head>

  • How to return error message using macro or others ways

    Hi !
    I need your help to find a technical solution.
    We have an alv object with 2 parameters (a checkbox and a writable field which is for address mail.) When you push the button B1, the function module SX_INTERNET_ADDRESS_TO_NORMAL is called to verify the email address.
    If I use the classic way to show the exceptions returned by the function module, the user can read the message but when he does an action on the program this dump. (The program has been killed.)
    I am looking for a way to show the error message and the possibility to change the email address. I think that using a popup information would work but I do not find this way very nice. Can I use macro to have the message on the status? In positive case, could you explain me how to use it?
    Thanks!

    check the context in which the message statement is running, [here in sap library - message processing|http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbaae335c111d1829f0000e829fbfe/frameset.htm], you will get the answer why!

  • Interrmittant dispaly of error message on JSP Page

    Hi ,
    I am developing an application using JSP and servlets. I ma having a peculiar issue with it.
    I have few links on a JSP page. When a user clicks on the link, its credentials are verified from database and if he is authorised, he will be taken to corresponding link page. Otherwise an error message is dispalyed on the same JSP page.
    When user is not authorised, an exception is thrown from backend to UI passing an error code. This error code is extracted in UI and error description for this error code is read from a properties file.
    From the servlet I use send.redirect() calls to redirect to the url with error code concatenated at the end of the url.
    It is something like this
    try {
    if(validUser)
    //do stuff
    response.sendRedirect("abc/xyzServlet");
    } catch(Exception ex) {
    errid=ex.getErrid();
    response.sendRedirect("abc/MainPageServlet?errid=" + errid);
    }In the MainPageServlet, i read error properties file and display error desc for that error id.
    The problem I am facing is that when an unauthorised user clicks on link repeatedly, he sees the error message intermittently.
    But the error id could be seen on the page url appended.
    Sometimes I also see IllegalStateException in the logs.
    I am using WebSphere server to deploy the application.
    Please help me on this, I have spent much time on this and haven't got a clue. Any pointers will be useful.
    Thank You,
    Priyanshu.
    Edited by: galapagos on Feb 28, 2008 10:43 PM
    Edited by: galapagos on Feb 28, 2008 10:44 PM

    I've tried this and the message still comes up all the time. Have also tried resetting and this doesn't work either. The message appears whether or not it is connected to an accessory (eg speakers). Any further ideas?

  • How to print error messages in browser?

    When I visit a jsp file in browser, there's some errors in the jsp file, so the browser returns
    The page cannot be displayed
    There is a problem with the page you are trying to reach and it cannot be displayed.
    I want the detail error messages, so I can debug my problem. How to print error message in browser or find the message in some log file?

    Hi Kanaraja,
    Thanks for your answer. I need to get certain information from the list. So, I use LIST_To_ASCII FM. However, may I know the ascii_tab should be type to what? And after this FM, do I have to use another FM to display the ascii list?
    data ABAPLIST type ABAPLIST OCCURS 0.
    SUBMIT  RPCALCU0 VIA SELECTION-SCREEN
    with PNPXABKR = 'US'
    with PNPTIMRA = 'X'
    with PNPPABRP = '10'
    with PNPPABRJ = '2003'
    with PNPPERNR-LOW = '100750'
    with PNPPERNR-LOW = '109202'
    with PNPPERNR-LOW = '100255'
    with PNPABKRS-LOW = 'US'
    with SCHEMA = 'ZUSP'
    with RADI_EDT ='X'
    with EDT_VARI = 'CUS&SAP_US'
    with TST_ON = 'X'
    EXPORTING LIST TO MEMORY and RETURN.
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject       = ABAPLIST
    EXCEPTIONS
       NOT_FOUND        = 1
       OTHERS           = 2.
    CALL FUNCTION 'LIST_TO_ASCI'
      EXPORTING
        list_index         = -1
      TABLES
        listasci           = asci_tab
        listobject         = ABAPLIST
      EXCEPTIONS
        empty_list         = 1
        list_index_invalid = 2
        OTHERS             = 3.
    IF sy-subrc NE '0'.
      WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.
    ENDIF.

  • After upgrading to Lion the bookmarks in Preview returns error message.

    After upgrading to Lion the bookmarks in Preview returns error message : The File "****" couldn't be opened because you don't have permission to view it. To change the perimssion, select the item in finder and Choose File info.  I have bookmarked plenty of files in Preview.  How to overcome this error message???

    Doesn't work Steve. I think it is an issue with Preview being sandboxed (check the sandbox column in Activity Monitor: Preview = Yes). Sandboxed apps restrict file access to those the user has explicitly selected. My theory is that this causes the unfortunate side effect of bookmarked or linked PDFs not working. A simple test: open a file with bookmarks, manually open the bookmarked file and then select the bookmark in the first file - it should open with no complaints about permissions (which leads to a weak workaround: open all the PDFs you intend to work with!).

  • How to show error message on page #NOTIFICATION_MESSAGE#?

    Hi,
    Is it possible to show error message on a page, where apex substitutes #NOTIFICATION_MESSAGE# at page template, with a javascript call? My requirement is to report error messages which i get from ondemand process, these on-demand processes were called from my javascript code. If any error message is returned by on-demand process, as of now, I'm reporting the error message to user by javascript based alert dialog box, but it would much better if i could keep the error message reporting by my application in a consistent manner. So any suggestion please?
    -Krishna

    Hi Roel,
    Thanks, jumping in for help.
    I tried your given code, i found that the page html source doesnt has any element with a name '#messages'. As per my understanding, its the apex engine which checks for any error, if found it shows it by adding an element id '#messages', but here on my requirement its not the apex engine which has detected the error, its my functional logic which wants to report a message. On a normal and error free page condition, we usually dont find '#message' element. I'm curious on how apex inbuilt engine is reporting an error to a page?

  • Prompt error message in JSP

    May I know how to prompt an error message in JSP?? can I use alert() as in javascript? what's the proper syntax to do it???

    Just to simplify what is already said: All JSP code, without exception, is executed on the server side, and when the JSP page is shown to the user (client) there is no execution of any JSP CODE, you can only use the information supplied by the JSP code.
    /R

  • How to prevent error message for material description in MDG material detail screen, when user click on check action

    Dear Experts,
    I have a requirement for making material description as non mandetory in change request view of mdg material screen.
    I have done that using field usage in get data method of feeder classes, but still message is displaying.
    This message 'Material description is mandatory is displaying with check action only, but not with save or submit after i anhance field property as not mandetory.
    How to prevent error message for material description in MDG material detail screen, when user click on check action.
    Thanks
    Sukumar

    Hello Sukumar
    In IMG activity "Configure Properties of Change Request Step", you can completely deactivate the reuse area checks (but will then loose all other checks of the backend business logic as well).
    You can also set the error severity of the checks from Error to Warning (per CR type, not per check).
    Or you provide a default value for the material description, e.g. by implementing the BAdI USMD_RULE_SERVICE.
    Regards, Ingo Bruß

  • How to give error message for the screen element text field when wrong i/p

    How to give error message for the screen element text field when wrong i/p
    when wrong input given
    eg. 
    I have a text box with SBOOK-CARRID
    so when user give wrong entry in text box i.e LG
    then I should give some error stating that the the input is invalid or not available ,
    now it showing the error of standard messages,
    i want manual message to be displayed when error comes.
    Thank you,
    Regards,
    Jagrut Bharatkumar Shukla

    Hi all,
    Thank you for your valuable reply,
    but the thing is that its a screen field,
    i.e text box not a selection screen
    i created in screen layout
    with name sbook-carrid
    now i want to get error message display if wrong i/p is given
    thank you.
    Regards,
    Jagrut bharatkumar Shukla,

  • How to make error message as warning message

    how to make error message as warning message? ie  i get error message hence cannot save the slaes order   i want to make that error message as warning so that i can save the sales order please help.

    Hi
    If a message is a custom message, then by changing the message type from E(Error) to W (warning)   we can convert the message type into error message. This is done with the help of development guy. A change in the code is needed.
    If it is a standard message, then it depends on whether we have teh access to change the message type. If access is there, then it is possible to change the message from Warning to Error. i.e. If we are capturing std SAP message in our code and displaying then we can change it, else if SAP message is displayed directly, we cant change it.
    So, to change it, capture the error message from SAP in some Zcode and then convert that message into a custom message of message type E.
    The whole change needs ABAP support.
    Try with tcode <b>OVA2</b> settings selecting for sales order or in SAPRO--SD-BF-Log of Incompletion Items
    Message was edited by:
            SHESAGIRI.G

  • How to display error message in abap

    How to dispaly error message in report?
    i have to check the range bewteen two days and if it is not in range have to display error message only once.
    next time if i press the execute button report will get executed without showing the warning message.
    i am calculating the days between two dates, i am displaying the error message but if i press the execute button i will not allow me to execute the report.it again shows me the error message.i have to skip this in 2nd time.
    can any one  suggest what to do with this?

    hello suman,
    i am using select-option in my report. And i have to check the difference between two dates in select option input box( low-value and high-value). if it is greater then suppose 10 then i have to display warning message at once and then if click on execute button , the report should get executed without showing any warning messages in report.
    here i am attaching my source code.please take a close look and tell me where should i have to make change.
    SELECT-OPTIONS :s_bedat FOR ekko-bedat.
    AT SELECTION-SCREEN ON s_bedat.
      IF NOT s_bedat IS INITIAL.
        PERFORM bedat_validate.                       " Perform for Purchasing Document Date Validation
      ENDIF.
    FORM bedat_validate .                        " Form for Purchasing Document Date Validation
      DATA  : diffr TYPE i.
      CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
        EXPORTING
          i_datum_bis                   = s_bedat-high
          i_datum_von                   = s_bedat-low
      I_KZ_EXCL_VON                 = '0'
      I_KZ_INCL_BIS                 = '0'
      I_KZ_ULT_BIS                  = ' '
      I_KZ_ULT_VON                  = ' '
      I_STGMETH                     = '0'
      I_SZBMETH                     = '1'
       IMPORTING
         e_tage                        =  diffr
    EXCEPTIONS
      DAYS_METHOD_NOT_DEFINED       = 1
      OTHERS                        = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        IF diffr GT 31.
          MESSAGE s009(zerrormsg) WITH text-000 DISPLAY LIKE 'W'.
          LEAVE TO LIST-PROCESSING.
        ENDIF.
      ENDIF.
    ENDFORM.                    " BEDAT_VALIDATE

  • How to display error message in Shopping Cart?

    How to display error message in Shopping Cart and stop the shopping cart for further processing? I try MESSAGE w001(zshop) or MESSAGE e001(zshop). But it is causing run-time error.

    Hi Paul,
    In the DOC_CHECK or DOC_SAVE BADI, you have a global internal table named et_messages. The structure of this table is 'bbp_smessages_badi'. You can append your error message here by inputting the message type, ID and number. The message type is either 'E' for error or 'W' for warning and the number would depend on your message class(ID). You will be able to see the error message on top of the screen, can be a red or yellow highlight depending on your appended message. I don't think creating the error message via the MESSAGE syntax will be successful, maybe this is why you are getting a runtime error.
    Regards,
    Noel

  • Latest version of Firefox is having problems loading sites, it tries to load to Google Analytics. No error messages, just a page that won't load. How do I stop this?

    Latest version of Firefox is having problems loading some sites, it tries to load and then gets taken over trying to load Google Analytics. No error messages, just a page that won't load. How do I get rid of this, it is a "pain in the neck"
    == URL of affected sites ==
    http://

    I just spent 3 days with this issue as well. I finally fixed it by reluctantly adding yet another add-on called ADBLOCK
    I was able to selectively block google-analytics. Now pages that weren't loading before are now loading.
    eg vimeo.com starbucks.com & other random sites.
    This was a tough one to fix because there is NO ERROR MESSAGE..page just shows it's loading...forever..& the bottom of my browser says 'waiting for google analytics'. I finally figured out google analytics is the culprit. Ironically, some help pages in trying to find a fix wouldn't load for me due to google analytics arghhh!
    Im on a macbookpro & Safari worked fine for these same sites. It was just Firefox. I nearly switched back to Safari because of this stupid issue.
    I'm wondering if this was caused by recent firefox 'updates'...

  • Best Practices Question: How to send error message to SSHR web page.

    Best Practices Question: How to send error message to SSHR web page from custom PL\SQL procedure called by SSHR workflow.
    For the Manager Self-Service application we’ve copied various workflows which were modified to meet business needs. Part of this exercise was creating custom PL\SQL Package Procedures that would gather details on the WF using them on custom notification sent by the WF.
    What I’m looking for is if/when the PL\SQL procedure errors, how does one send an failure message back and display it on the SS Page?
    Writing information into a log or table at the database level works for trouble-shooting, but we’re looking for something that will provide the end-user with an intelligent message that the workflow has failed.
    Thanks ahead of time for your responses.
    Rich

    We have implemented the same kind of requirement long back.
    We have defined our PL/SQL procedures with two OUT parameters
    1) Result Type (S:Success, E:Error)
    2) Result Message
    In the PL/SQL procedure we always use below construct when we want to raise any message
    hr_utility.set_message(APPL_NO, 'FND_MESSAGE_NAME');
    hr_utility.raise_error;
    In Exception block we write below( in successful case we just set the p_result_flag := 'S';)
    EXCEPTION
    WHEN APP_EXCEPTION.APPLICATION_EXCEPTION THEN
    p_result_flag := 'E';
    p_result_message := hr_utility.get_message;
    WHEN OTHERS THEN
    p_result_flag := 'E';
    p_result_message := hr_utility.get_message;
    fnd_message.set_name('PER','FFU10_GENERAL_ORACLE_ERROR');
    fnd_message.set_token('2',substr(sqlerrm,1,200));
    fnd_msg_pub.add;
    p_result_message := fnd_msg_pub.get_detail;
    After executing the PL/SQL in java
    We have written some thing similar to
    orclStmt.execute();
    OAExceptionUtils.checkErrors (txn);
    String resultFlag = orclStmt.getString(provide the resultflag bind no);
    if ("E".equalsIgnoreCase(resultFlag)){
    String resultMessage = orclStmt.getString(provide the resultMessage bind no);
    orclStmt.close();
    throw new OAException(resultMessage, OAException.ERROR);
    It safely shows the message to the user with all the data in the page.
    We have been using this construct for a long time for all our projects. They are all working as expected.
    Regards,
    Peddi.

Maybe you are looking for