Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJWCD
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Web Component Certification (OCEJWCD)
El doubt
sri latha
Greenhorn
Posts: 27
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
ScopedVars.java
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class [url=http://ScopedVars]ScopedVars[/url] extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("attribute1", "First Value"); HttpSession session = request.getSession(); session.setAttribute("attribute2", "Second Value"); ServletContext application = getServletContext(); application.setAttribute("attribute3", new java.util.Date()); request.setAttribute("repeated", "Request"); session.setAttribute("repeated", "Session"); application.setAttribute("repeated", "ServletContext"); RequestDispatcher dispatcher = request.getRequestDispatcher("Cart/scoped-vars.jsp"); dispatcher.forward(request, response); }}
scoped-vars.jsp
<!DOCTYPE �> �<%@ page isELIgnored="false" %> <TABLE BORDER=5 ALIGN="CENTER"> <TR><TH CLASS="TITLE"> Accessing Scoped Variables </TABLE> <P> <UL> <LI><B>attribute1:</B> ${attribute1} <LI><B>attribute2:</B> ${attribute2} <LI><B>attribute3:</B> ${attribute3} <LI><B>Source of "repeated" attribute:</B> ${repeated} </UL> </BODY></HTML>
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee [url=http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"]http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"[/url] version="2.4">
Can anyone Please explain why my scoped-vars.jsp is not displaying the attribute values from
servlet
. It is simply displaying the output like this.
attribute1:
attribute2:
attribute3:
Source of "repeated" attribute
Thanks in advance
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Already answered the same one yesterday !
https://coderanch.com/t/291490/JSP/java/Accessing-scoped-variables-EL
[My Blog]
All roads lead to JavaRanch
sri latha
Greenhorn
Posts: 27
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Sorry satou still iam not getting the output. May be i think my
jsp
is not recognising the servlet. can any one help me.
Marc Peabody
pie sneak
Posts: 4727
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Everything
seems
right. Be sure that the URL in your browser is pointing to the mapped servlet and not to the JSP.
A good workman is known by his tools.
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Mmh, everything looks fine indeed.
Did you try removing the DOCTYPE in your jsp file ?
[My Blog]
All roads lead to JavaRanch
sri latha
Greenhorn
Posts: 27
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thank you Marc, you are right. i didnt even think when we call servlet only it forwards to jsp.not vice versa according to the code.
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
EL functions
JSP values not being generated
TOMCAT 5.5.4 + Datasource in ROOT not working
Doubt in EL's sequence
how to send parameter from html to jsp??
More...