Results 1 to 6 of 6
  1. #1
    Sachin. is offline Member
    Join Date
    Mar 2009
    new delhi
    Rep Power

    Question Problem with jsp using struts......

    hiii friends
    i m a student and working on one project using j2ee with struts framework, in which now i m making a page called " feedback " ,i got success in submitting the values from the feedback page to the database.

    my succes and errors path is same that is " feedback" page. so whenever user enters wrong or right data in the feedback page it will dispatch to the feedback page again with errors.

    till here i m able to show the errors on the feedback page but i want to show a successfull message to show user that he or she successfully submitted their feedback.

    problmem 1 - how can i show a successfull message only after the successfull entry of data in the database ?

    My 2nd problem is that whnever user enters data successfully it again comes back to feedback . But when it comes back all the data fields should hav to be null values but it does'nt hav.

    problem 2 - how can i set d null value(blank) to all the data fields after the successfull submission of data ?

    one thing i want to remind u tht m using struts framework in which text fields does'nt hav d id feild by wich i cud achieve d this target using javascript.

    please show me right waut to solve these problems.
    thanks in advance.......

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Rep Power


    You configure that in the action tags in your struts.xml

    All your questions are easily answered by referring the struts tutorial that came with your struts download.
    Here is an online version.

  3. #3
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Hong Kong
    Rep Power


    you may use actionmessage if success and actionerror, fielderror for fail

  4. #4
    Sachin. is offline Member
    Join Date
    Mar 2009
    new delhi
    Rep Power


    mtyoung sir,

    i got the point , that how to use ActionMessages , but m not able to understand how i can show this message after successfull insertion of data on the jsp page.

    beacuse we use <html:errors/> to show erros on jsp page. But in the case of success how can i show the successfull msg ??

    please give me example if u can .

    thanks for help

  5. #5
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Rep Power


    Hi Sachin,
    Gothru this thread and if u get any errors,send the cocde and I will have a look

    Using ActionMessages in struts

  6. #6
    Sachin. is offline Member
    Join Date
    Mar 2009
    new delhi
    Rep Power

    Default sorry for late reply RamyaSivakanth's Sir

    thanks sir for helping me......

    i read your given link and tried to implement it but i did'nt get the right answer after implementing the ActionMessage Class .

    my code is here:-
    Java Code:
    this is my jsp page code: -
     <html:form action="login" method="get"  >
                <html:text property="name" name="loginbean" styleId="myname" 
    onclick="email(document.getElementById('myname'), 'Please Enter a Value')">
                <html:text property="pass" name="loginbean" ></html:text>
                <html:submit > Submit</html:submit>
    this is my action class code:-
    public class loginaction extends Action {
        /* forward name="success" path="" */
        private final static String SUCCESS = "success";
         private final static String FAILURE = "errors";
        public ActionForward execute(ActionMapping mapping, ActionForm  form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
            ActionErrors errors = new ActionErrors();
             ActionMessages messages = new ActionMessages();
               ActionMessage msg = new ActionMessage("data.ok");
              messages.add("message1", msg);
              msg = new ActionMessage("data.continue");
              messages.add("message2", msg);
              String str = " u r rite user";
                   saveMessages(request, messages);
            loginbean lb = (loginbean)form;
            String nm = lb.getName();
            String pa = lb.getPass();
            String strname = "sachin";
            String strpass = "kumar";
            if(strname.equals(nm) && strpass.equals(pa))
               String sname = null;
               sname = strname;
               String commsg = sname + str ;
                return mapping.findForward(SUCCESS);
        return null;
    this is my welcome page code:-
                    <html:messages id="msg" message="true" property="message1">
                        <bean:write name="msg"></bean:write> <br>
    i m asking about this because i have 1 password recovery page in which i have 1 user name field , 1 password question field , 1 password answer field and submit button. so whenever user enter rite username , pass. qs nd pass. ans than d password shud be show on d same page below these fields . nd this msg only show on d successfull insertion of data not on d page load .

    for eg:- Your password is - mycomputer.

    thank you...

Similar Threads

  1. Problem with my first Struts program....please help me
    By sireesha in forum Web Frameworks
    Replies: 5
    Last Post: 10-16-2011, 04:19 PM
  2. decorator.jsp problem building Struts Menu in JSP when Struts action is used
    By dkirvan in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-29-2010, 05:33 AM
  3. URL Problem with IE7 in my struts Application
    By SreenivasGurramkonda in forum Web Frameworks
    Replies: 0
    Last Post: 11-27-2008, 08:14 AM
  4. Problem with struts
    By oferk78 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 09-11-2008, 07:14 PM
  5. Struts problem
    By ziniestro in forum Web Frameworks
    Replies: 2
    Last Post: 05-10-2007, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts