• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

EL s not running

 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hava to class in package foo.
package foo;
public class Person {
public String name;
public Dog dog;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Dog getDog(){
return dog;
}
public void setDog(Dog dog){
this.dog=dog;
}}
package foo;
public class Dog{
public String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}}
and a servlet
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class s1 extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws IOException,ServletException{

foo.Person p = new foo.Person();
p.setName("Evan");

foo.Dog dog=new foo.Dog();
dog.setName("Spike");
p.setDog(dog);
req.setAttribute("person",p);
RequestDispatcher view =req.getRequestDispatcher("result.jsp");
view.forward(req,res);
}}

now when I use this- Dog's name is : ${person.dog.name} in result.jsp then I get the output
Dog's name is : ${person.dog.name} instead of getting "spike"
but this is working fine --
<%= ((foo.Person) request.getAttriute("person")).getDog().getName() %>
Why ?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably did not set your web.xml properly. Check this FAQ, especially this section (servlets 2.4)
 
mooooooo ..... tiny ad ....
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!