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.


>> REGISTER NOW TO START POSTING


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
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default RequestDispatcher forward and attribute / variable saving

    Hi
    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:
                if(signInButton!=null){
    			String communicat=null;
    			username=loginAuthorization(request);
    			if(username.equals("bad")==false)
    			{
    				Album album=new Album();
    				url=base+studioAlbumsPollVote;
    			}
    			else{
    				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
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 697 Times in 679 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, 09:04 PM
  3. Replies: 1
    Last Post: February 14th, 2013, 06: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, 12: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, 08:04 AM

Tags for this Thread