Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Concept not clear - HFSJ Page NO - 385

sakthikumaran navakumar
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am not clear with the concept given in Page no - 385. Itz regarding requestScope.

Please some body help me out.

Thanks and Regards,

khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sakthikumaran Navakumar

What you could not understand on that page.

There are only two things that are explained on that page..

Firat is that you can avoid naming conflict, if there are more than one variable with the same name in different scope by prefixing them with respective implicit scope object.
For e.g.
${} gives you the respective property of the bean in the request scope.
${} gives you the same property for the object stored in session scope.

And second thing is you can have that strings as a varible name which are not allowed by java convention.

e.g if you write ${}, the container will try to search for the person bean if foo package. However there is no foo package in reality in your application.
Actually foo.person is a bean set by your servlet by doin someting like this
HttpSession session = request.getSession();
Person person = new Person();
session.setAttribute("foo.person", person);

And you want to retrieve that in your JSP.
The container will resolve the problem if, you will write something like this
Because [] operator can resolve non conventional property name.
Moreover by writing this, you are telling the container to search for the property in the session scope. It will also avoid the naming conflict if some property exists in requestscope also.

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic