Hi Ganesh,
here is my complete code.
Please try to figure out where the problem lies.
I am getting it worked with ${person.name} but not with ${person.dog.name}
If there is any doubt regarding my presentation..please ask me.
Thanks in advance,
javainn
first file:
form1.html(I am calling this from IE)
<html>
<body>
<form method="post"action="Test.do">
<h1>
Testing usage of Scriptless
JSP's</h1>
<input type="submit"value="submit">
</form>
</body>
</html>
2nd file-Test.java(Control goes to this
servlet next)
package com.example;
import com.example.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class Test extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
com.example.person p=new com.example.person();
p.setName("JIMMY");
com.example.Dog dog=new com.example.Dog();
dog.setName("Tommy");
p.setDog(dog);
request.setAttribute("person",p);
RequestDispatcher view=request.getRequestDispatcher("final.jsp");
view.forward(request,response);
}
}
3rd file ( Dog.java)
package com.example;
public class Dog{
static
String name;
public static String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
}
last file(final.jsp)
<html>
<body>
<h1>The Name Is:</h1>
${person.dog.name}
</body>
</html>
her eits giving the error.
The directory com is under web-apps,app-name,classes.
web.xml for your ref is :
<web-app xml="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>testname</servlet-name>
<servlet-class>com.example.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testname</servlet-name>
<url-pattern>/Test.do</url-pattern>
</servlet-mapping>
</web-app>
[ April 01, 2005: Message edited by: S javainn ]
[ April 02, 2005: Message edited by: S javainn ]