• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EL s not running

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably did not set your web.xml properly. Check this FAQ, especially this section (servlets 2.4)
 
A wop bop a lu bop a womp bam boom! Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic