Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Tolls

Thread: Help about option select in jsp page

  1. #1
    langtu_hqb is offline Member
    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Unhappy Help about option select in jsp page

    I want get value in option select in jsp page . My code is here :
    Java Code:
    <body>
    <form action="loadData" method="post">
    	<select id="abc" name="abc">
    		<option value="1">get 1</option>
    		<option value="2">get 2</option>
    		<option value="3">get 3</option>
    		<option value="4">get 4</option>
    		
    	</select>
    
    	<%
    		String name=request.getParameter("abc");
    		session.setAttribute("trans",name);
    	%>
    <input type="submit" value="Report">
    </form>
    
    </body>
    I use request.getParameter("abc") to take value and set Attribute to send to controller, but value get is null. Help me !! :(((((

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Help about option select in jsp page

    You can't get the contents of a request in the page that makes the request, unless that page is also the destination.

    When you first go to this page it is not from this form.
    langtu_hqb likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,104
    Rep Power
    6

    Default Re: Help about option select in jsp page

    Quote Originally Posted by langtu_hqb View Post
    I use request.getParameter("abc") to take value and set Attribute to send to controller, but value get is null. Help me !! :(((((
    So given what Tolls said, BEFORE or AFTER you press submit? Before it is indeed most definitely going to be null.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    langtu_hqb is offline Member
    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Default Re: Help about option select in jsp page

    Quote Originally Posted by Tolls View Post
    You can't get the contents of a request in the page that makes the request, unless that page is also the destination.

    When you first go to this page it is not from this form.
    Thank u. Can you help me get value this page???

  5. #5
    langtu_hqb is offline Member
    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Default Re: Help about option select in jsp page

    It's my demo. My project look is picture : Help about option select in jsp page-hinh.jpg . I want select value in select Giảng Viên and after submit Report, all value are add to arraylist and send to controller . Do you understand and help me???
    Attached Thumbnails Attached Thumbnails Help about option select in jsp page-hinh.jpg  

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,104
    Rep Power
    6

    Default Re: Help about option select in jsp page

    All of a sudden you have a table, which you don't have in that snippet you posted in the first post. Post the -actual- code you are having trouble with. ALSO the server-side code invoked after submission, not just the JSP.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 0
    Last Post: 06-28-2013, 08:17 AM
  2. Replies: 6
    Last Post: 01-30-2013, 03:43 AM
  3. JAX-WS\METRO - apt with option option key="r"
    By Talkinjive in forum Web Frameworks
    Replies: 0
    Last Post: 01-31-2010, 04:15 PM
  4. A Question on <select><option> tag
    By sayan751 in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 09-14-2009, 06:05 AM
  5. How to retain value in struts 2 using <s:select></s:select> tag
    By SaiPrasad@Sella in forum Web Frameworks
    Replies: 0
    Last Post: 02-09-2009, 07:23 AM

Posting Permissions

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