?
Solved

Two JSP Tags in 1 HTML page

Posted on 2006-11-02
6
Medium Priority
?
228 Views
Last Modified: 2010-04-01
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?
0
Comment
Question by:CSecurity
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 17857002
have u tried

<%= a %>
0
 
LVL 3

Accepted Solution

by:
KnightFire earned 1500 total points
ID: 17857486
Scope in JSPs is the same as java, if you get really stuck then examine the generated servlet that is created from the JSP.

objects comment is correct as <%= a %> should print the value of a. If it doens't then a must have gone out of scope, meaning you probably defined it within a loop or similar in the first set of JSP tags. Make sure that a is defined outside any loops or other constructs within the tags.
0
 
LVL 17

Author Comment

by:CSecurity
ID: 17857801
Again I got error in this line:

 out.print( titles[0] );

But I defined them at TOP of opening of <% JSP tag
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:KnightFire
ID: 17857918
can you paste your JSP page?
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17858336
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

%>
..
0
 
LVL 17

Author Comment

by:CSecurity
ID: 17860265
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question