Link to home
Start Free TrialLog in
Avatar of CSecurity
CSecurityFlag for Iran, Islamic Republic of

asked on

Two JSP Tags in 1 HTML page

Hello!

I have a JSP page and I open <% jsp tag in it. Then I close it with %>

In first tag I define a variable: int a = 23;

Then I put a lot of HTML code... Now I want to print 'a' variable in middle of html. So I re-open <% JSP tag.

But it says 'a' is not defined!

What should I do?
Avatar of Mick Barry
Mick Barry
Flag of Australia image

have u tried

<%= a %>
ASKER CERTIFIED SOLUTION
Avatar of KnightFire
KnightFire

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CSecurity

ASKER

Again I got error in this line:

 out.print( titles[0] );

But I defined them at TOP of opening of <% JSP tag
Avatar of KnightFire
KnightFire

can you paste your JSP page?
Make sure for every opening <% , there is a closing %>
Make sure all html tags are closed properly.

<html tags>

<%

All your java code

%>

<html tags>

<%

All your java code

%>
..
The problem was that I should define them at TOP of code... it was in try and catch! ALTOUGHT everytime it goes to try and never goes to catch (no error occurs) but it should define before everything!

Thanks all