Solved

Two JSP Tags in 1 HTML page

Posted on 2006-11-02
6
211 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
6 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
have u tried

<%= a %>
0
 
LVL 3

Accepted Solution

by:
KnightFire earned 500 total points
Comment Utility
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
Comment Utility
Again I got error in this line:

 out.print( titles[0] );

But I defined them at TOP of opening of <% JSP tag
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 3

Expert Comment

by:KnightFire
Comment Utility
can you paste your JSP page?
0
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now