Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: RequestDispatcher forward and attribute / variable saving

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Thanked 0 Times in 0 Posts

    Default RequestDispatcher forward and attribute / variable saving

    I am begginer with java ee(servlets,jsp etc.).
    I am writting simple Web Application with login service.
    I have override method
    doPost(HttpRequest request,HttpResposne response)
    My idea is check valid of username and if is valid then send this with requestDispatcher forward:
    			String communicat=null;
    				Album album=new Album();
    				communicat="error login or password";
    			request.setAttribute( "communicat",  communicat);
                  RequestDispatcher requestDispatcher=request.getRequestDispatcher(url);
    		requestDispatcher.forward(request, response);
    I was trying to use HttpSession setParametr and getParametr but after using forward method getParametr return null string. How can i pass username string for next doPost()?

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: RequestDispatcher forward and attribute / variable saving

    Welcome to the forum! Thanks for taking the time to learn how to post code correctly. If you haven't already, please read this topic to learn other useful info for new members.

    This subject is probably used more as a tutorial subject than any other. Search the 'net for one (or several) of those and work through them.

Similar Threads

  1. RequestDispatcher include()
    By Shikhir in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 15th, 2013, 12:40 PM
  2. Replies: 149
    Last Post: February 19th, 2013, 10:04 PM
  3. Replies: 1
    Last Post: February 14th, 2013, 07:30 PM
  4. Saving string value of an iterator Object into a variable.
    By apocalipsis1982 in forum What's Wrong With My Code?
    Replies: 16
    Last Post: December 28th, 2011, 01:12 PM
  5. returning variable and saving to file
    By ravencrest in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: November 18th, 2011, 09:04 AM

Tags for this Thread