|
-
Aug 19th, 2004, 08:27 AM
#1
Thread Starter
Fanatic Member
How to Declare Global Variables??
I am just starting out with Java, and I have been fairyl sucessful with creating some basic JSP's.
I am attempting to convert a VB project into a Web application...
I have a question though, that I have been unable to find a clear cut answer to...and that is, how can I declare Global variables within a JSP that can be called from other JSP's...
or am I going about the theory all wrong...For example when I have the user select a month & year on a JSP, and then they click on a Submit button, this should take them to the next JSP, which will need to have the values of the month year to use within a SQL statement...
I hope that I am clear, and I hope that someone can give me some helpful pointers...
Thank you!
-
Aug 19th, 2004, 08:29 AM
#2
You would need to either add to the query string or add the variables to the session.
Sorry, can't provide a specific example. I haven't used Java in a while.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Aug 19th, 2004, 08:47 AM
#3
Thread Starter
Fanatic Member
I appreciate your response, but unfortunately I am going to need a little bit more...such as how to add the vaiables to a session, or to the query string??
I have the variables stored in the following way:
Code:
<html>
<title>Selection</title>
<head>
<script language="JavaScript">
function Month()
{
var m = document.form2.list2.selectedIndex;
}
function Year()
{
var y = document.form1.list1.selectedIndex;
}
</script>
<FORM><style media="screen" type="text/css"><!--
.plainText {font-family: arial; font-size: 8pt; font-weight: normal; color: black; text-decoration: none}
A {color: black; font-weight: normal; font-size: 8pt; font-family: arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: arial, helvetica, sans-serif }
A:hover {color: red; font-weight: normal; font-size: 8pt; font-family: arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: arial, helvetica, sans-serif}
A.final:active { color: black; font-weight: bold; font-size: 8pt; font-family: arial, helvetica, sans-serif; text-decoration: none; pt: font-family: arial, helvetica, sans-serif }
.topbarText1 { font-family: Arial; font-size: 10pt; font-weight: bold; color: #FFFFFF; text-decoration: none }
.topbarText2 { font-family: Arial; font-size: 8pt; color: #FFFFFF; text-decoration: none }
.bannerText { font-family: Arial; font-size: 8pt; font-weight: bold; color: #000000; text-decoration: none }
.topbarText { font-family: Arial; font-size: 8pt; font-weight: bold; color: #FFFFFF; text-decoration: none }
.topbarText:hover { font-family: Arial; font-size: 8pt; font-weight: bold; color: red; text-decoration: none }
--></style>
<table border="0" cellpadding="1" cellspacing="0" >
<tr><td valign="top" align="left">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR VALIGN=top><CENTER>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR VALIGN=top><TD WIDTH="272"><FONT SIZE=2><img name="DIRECT BANKING-MAINHSBC LOGO" src="http://het7/HsbcGreyLogo.gif" border="0"></img></FONT>
</TD><TD WIDTH="848"><div align=right><img name="CPMS HEADING" src="http://het7/CPMShead.jpg"</TD></TR></div>
</TABLE>
</CENTER></TD></TR>
</td></tr>
</table>
<table border="0" width=100% bgcolor=darkblue cellpadding="0" cellspacing="0"><tr><td><font class="topbarText1"> <i>CPMS</i></font></td>
<td align="right">
</td></tr></table>
</td></tr>
<tr bgcolor="#FFFFFF"><td colspan="2"></td></tr>
<tr bgcolor="#000000"><td colspan="2"></td></tr>
</table></FORM>
<center>
<table border="1" cellspacing="0" cellpadding="3" bordercolor=white>
<tr valign="top">
<tr><font color=white>Space</font></tr>
<tr><font color=white>Space</font></tr>
<tr><font color=white>Space</font></tr>
<td width=900 align=center><font size = 5 color="330099"><b>Please select the Year, Month or Quarter</b></font><p>
<FORM NAME="form1"><font size=3 color="990033">Year
<SELECT NAME="list1" onChange="Year()">
<OPTION VALUE="2004">2004
<OPTION VALUE="2005">2005
<OPTION VALUE="2006">2006
<OPTION VALUE="2007">2007
<OPTION VALUE="2008">2008
<OPTION VALUE="2009">2009
<OPTION VALUE="2010">2010
<OPTION VALUE="2011">2011
</SELECT>
</FORM>
<FORM NAME="form2"><font size=3 color="990033">Month
<SELECT NAME="list2" onChange="Month()">
<OPTION VALUE="January">January
<OPTION VALUE="February">February
<OPTION VALUE="March">March
<OPTION VALUE="April">April
<OPTION VALUE="May">May
<OPTION VALUE="June">June
<OPTION VALUE="July">July
<OPTION VALUE="August">August
<OPTION VALUE="September">September
<OPTION VALUE="October">October
<OPTION VALUE="November">November
<OPTION VALUE="December">December
</SELECT>
</FORM>
<form name=f2 action='selection2.jsp'>
<center><input type=submit value='Complete' name=></center>
</table>
</center>
</body>
</head>
</html>
So when the next JSP loads I need to pass the values for the month and year which are set to m & y from the functions above...
Any help will be greatly appreciated!
-
Aug 19th, 2004, 10:58 AM
#4
Dazed Member
Posted by crptcblade
I haven't used Java in a while.
Been using that VB again hugh?
-
Aug 23rd, 2004, 05:11 AM
#5
Fanatic Member
me too use vb. anyways, try this one
document6.jsp
Code:
<style>
body{
font:9pt arial;
}
select{
font:9pt arial;
}
</style>
<form action=document7.jsp>
Year
<select name='lstyear'>
<option value='2004'>2004
<option value='2005'>2005
<option value='2006'>2006
<option value='2007'>2007
<option value='2008'>2008
<option value='2009'>2009
<option value='2010'>2010
<option value='2011'>2011
<option value='2012'>2012
</select>
Month
<select name='lstmonth'>
<option value='january'>january
<option value='february'>february
<option value='march'>march
<option value='april'>april
<option value='may'>may
<option value='june'>june
<option value='july'>july
<option value='august'>august
<option value='september'>september
<option value='october'>october
<option value='november'>november
<option value='december'>december
</select>
<p>
<input type=submit value='complete'>
</form>
document7.jsp
Code:
<style>
body{
font:9pt arial;
}
</style>
<%
out.print("The month was "+request.getParameter("lstmonth")+
" and the year was "+request.getParameter("lstyear"));
%>
does this help? if not, sorry.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|