?
Solved

How do I make a variable available to many scriptlets in a JSP?

Posted on 2005-03-17
3
Medium Priority
?
348 Views
Last Modified: 2010-04-01
How do I make a variable available to many scriptlets in a JSP?

i.e., I have a string obtained from a session object and would like to convert it into an integer to be used in several scriptlets in  my JSP.

The following does not work:

I would like to use int MAX_NUM in the scriptlets, when MAX_NUM has the value obtained from session object numActiveSDPsDiag.

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head><title>JSP Page</title></head>
<body>

<table align="center" width="70%" border="0" background="blue_marble.gif">
<tr>
<td align="center"><font color="gold" size=6><br>SERVICE DELIVERY POINT RANKING </font><br><br></td>
</tr>
</table>

<table align="center" width="70%" border="0" background="blue_rock.gif">
<tr>
<td align="left">
<b> Service Delivery Point Ranking in Number of Diagnosises made: </b><br>

<% String theLimit = (String) session.getAttribute("numActiveSDPsDiag"); %>

<%! int MAX_NUM = Integer.parseInt(theLimit); %>
   
<%
String[] sdpNames = (String[]) session.getAttribute("sdpNames");
String[] numOccurancesDiag = (String[]) session.getAttribute("numOccurancesDiag");
for (int i = 0; i< MAX_NUM; i++) {
     String name = sdpNames[i];
     String occurance = numOccurancesDiag[i];
%>
</tr>
<tr>
  <td align="left" valign="top"><%= name %> </td>
  <td align="left" valign="top"><%= occurance %></td>
</tr>
<%
}
%>
<br>

<tr>
<td align="left"> <b> Service Delivery Point Ranking in Number of Patient Visits made: </b><br>
<%
String[] visitedSDP = (String[]) session.getAttribute("visitedSDP");
String[] occuranceOfVisits = (String[]) session.getAttribute("occuranceOfVisits");
for (int i = 0; i< MAX_NUM; i++) {
     String sdp = visitedSDP[i];
     String occurance = occuranceOfVisits[i];
%>
<tr>
  <td align="left" valign="top"><%= sdp %> </td>
  <td align="left" valign="top"><%= occurance %></td>
</tr>
<%  
}
%>
<br>
</td>
</table>

</body>
</html>

I do appreciate your kind instruction
0
Comment
Question by:Rrugemalira
[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
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Manish earned 500 total points
ID: 13572113
<% String theLimit = (String) session.getAttribute("numActiveSDPsDiag");

 int MAX_NUM = Integer.parseInt(theLimit);
%>
karan
0
 

Assisted Solution

by:sujata7576
sujata7576 earned 500 total points
ID: 13573068
<%
int MAX_NUM  = 0;
String theLimit = (String) session.getAttribute("numActiveSDPsDiag");
if(theLimit != null)
   MAX_NUM  = Integer.parseInt(theLimit);
%>
0
 
LVL 11

Expert Comment

by:Manish
ID: 13581054
Thank you for points..! :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Summer 2017 Scholarship Winners have been announced!
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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