Hi all. I hope this isn't too much of a newbie question though it is
fundamental
to JSP development and I may have missed something really obvious. <g>
If I have a file named real.jsp and a file named blob.jsp and real.jsp
includes
blob.jsp to display a message with special formatting. They both make use of
a
java class. How to I impose scope upon the variables so that I don't get
"variable
already declared" type errors?
The two files are included below. They fail on the useBean line (already
declared)
and on the message line (same). It's not much use if any file which may be
included
has to use strange essoteric variable names just to avoid possible conflicts
with
files which may include it.
BTW: Is application.set/getAttribute() the best way to pass information to a
file
to be included?
<%------------------------------------------------------------%>
<%@ page language="Java" %>
<%-- real.jsp --%>
<jsp:useBean id="ju" class="com.netbyte.util.JspUtils" scope="page" />
<%!
String message = "Blyech";
%>
<html>
<head>
<title>Scope Test</title>
</head>
<body>
<% application.setAttribute("blob.message", message); %>
<%@ include file="blob.jsp" %>
</body>
</html>
<%------------------------------------------------------------%>
<%@ page language="Java" %>
<%-- blob.jsp --%>
<jsp:useBean id="ju" class="com.netbyte.util.JspUtils" scope="page" />
<%!
String message = (String) application.getAttribute("blob.message");
%>
<table border=0>
<tr>
<td>
<p><big><%= message %></big></p>
</td>
<tr>
</table>
<%------------------------------------------------------------%>
Zach.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets