Hallo everyone,
this example is not working for me
The rest of the examples in this chapter depend on this one so basically i am stock overhere
when i run the application i get no outupt and the parameter (user name) is passed in the URL. e.g. if i put "john" this is what i get in the address bar
http://localhost:8080/Beans3/result.jsp?userName=john any clue?
***************************************
form.html
<html><body>
<form action="result.jsp">
name: <input type = "text" name="userName">
<input type="submit">
</form>
</body></html>
******************************************
result.jsp
<html><body>
<
jsp:useBean id="person" class="com.example.web.Person" >
<jsp:setProperty name="person" property="name"
value="<%=request.getParameter("userName")%>" />
</jsp:useBean>
</body></html>
*******************************************************
java bean Person.java
package com.example.web;
public class Person {
private
String name;
public void setName(String n)
{
name=n;
}
public String getName()
{
return name;
}
}//Person
**********************************
Test.java
package com.example.web;
import com.example.web.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class
Test extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
Person p = new Person();
p.setName("Evan");
request.setAttribute("person",p);
RequestDispatcher view= request.getRequestDispatcher("result.jsp");
view.forward(request,response);
}
}
**********************************
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.4">
<
servlet>
<servlet-name>BeansTest</servlet-name>
<servlet-class>com.example.web.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BeansTest</servlet-name>
<url-pattern>/Tester.do</url-pattern>
</servlet-mapping>
</web-app>
[ June 14, 2005: Message edited by: Jamed ]
[ June 14, 2005: Message edited by: Jamed ]
[ June 14, 2005: Message edited by: Jamed ]
[ June 14, 2005: Message edited by: Jamed ]