We help IT Professionals succeed at work.

How to use variables from a main JSP page to an included JSP page?

_Esam
_Esam asked
on
742 Views
Last Modified: 2008-11-29
Hi,

I have a main JSP page where header, and two more JSP pages are included dynamically like:

In main.jsp page

<%@ include file="mainheader.jsp" %>


Now in the main.jsp page, there are some variables declared

like:
<%

String screen=null;
String sort=null;
String where=null;

%>

which are later used in the included JSP like mainheader.jsp as

if (userType == "E" && !screen.equals("asnhome")) {
String checkHacker = HttpHeaderParser.encodeString(where);

}


Now RAD 7 shows these (screen, where)  as errors in the mainheader.jsp page?

This app was initially built with WAS 5.1.2

I am trying to convert it to WAS 6.1


What is the problem here?


Thanks.
_Esam
Comment
Watch Question

CERTIFIED EXPERT

Commented:
RAD 7 will treat mainheader.jsp as another j sp.

In order to avoid compilation error

you can try like this

<%@ include file="mainheader.jsp" %>

as
<%@ include file="mainheader.jspf" %>

Let me know if any concerns

Principal Technologist
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
will a request.setAttribute and a request.getAttribute work?
Mayank SPrincipal Technologist
CERTIFIED EXPERT

Commented:
I believe my comment was correct because eventually when the application is run on the server, it won't give the same error as what the development IDE RAD is giving.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.