Welcome, Guest. Please login or register.
Did you miss your activation email?
Pages: [1]   Go Down
  Print  
Author Topic: Retrieve data from a form from a bean.  (Read 1469 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2593
Referrals: 13

WWW Awards
« on: October 11, 2007, 03:40:30 PM »

In the JSP:

Code
GeSHi (html4strict):
  1.    <FORM METHOD=POST ACTION="View.jsp">
  2.      <H5>
  3.      <p>InputText:        <INPUT TYPE= TEXT NAME=text</H5><br>      
  4.  </FORM>
Created by GeSHI 1.0.7.20

And:

  <jsp:useBean id="key" class="your.bean.ViewData" scope="request"/>
  <jsp:setProperty name="key" property="*"/>


Your bean:
Code
GeSHi (java):
  1. public String getText(){
  2. System.out.println("ViewData.getText()" + text);
  3. return text;
  4. }
  5.  
  6. public void setText(String text){
  7. this.text = text;
  8. }
Created by GeSHI 1.0.7.20

Your servlet:

Code
GeSHi (java):
  1. public void doPost(HttpServletRequest request, HttpServletResponse response)
  2.  throws ServletException, IOException
  3.  {
  4.  System.out.println("("+id+")ViewControl.doPost()");
  5. request.getAttribute("SUBMIT");
  6. request.getParameter("text");
  7.  
  8.  
  9. }
Created by GeSHI 1.0.7.20

And:

Code
GeSHi (java):
  1.      TextIF port = (TextIF)service.getPort(TextIF.class);
  2.      ViewData vd = new ViewData();
  3.      request.setAttribute("key", vd);
Created by GeSHI 1.0.7.20
« Last Edit: December 09, 2007, 03:21:38 PM by HappyFace » Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here