• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to send object from servlet to jsp without using Scoped variables

 
satyaprasad veeramsetti
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, how can we send any object ,from servlet to jsp but below conditions apply
a)don't use scoped variables and
b)Jstl with EL-exepresions.
please let me know is there any another way of sending object to jsp from servlet...

Thanks in advance
Satyaprasad
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a puzzle? An interview question?

Because otherwise it makes no sense to not used scoped variables for their intended purpose.
 
satyaprasad veeramsetti
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please send me the answer for the question
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please answer mine first. Without knowing the reason for the strange question, it's impossible to guess what the restrictions are.
 
Stefan Evans
Bartender
Posts: 1692
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is meant by "scoped variables"? Are you referring to attributes or something else?
Is that constraint you are meant to use JSTL/EL or prohibited from doing so (and if prohibited, why?)

The standard way to pass an object from a servlet to a JSP is as an attribute in scope.
From the servlet:



You then access it on the JSP page via EL: ${requestScope.myVal} or just ${myVal} which would result in 42.
similarly for ${sessionScope.mySessionVal} and ${applicationScope.myApplicationVal}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, those are scoped variables. But we're still waiting for the OP to explain why they need to be avoided.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic