jsp:Applicaton(100分)

B

bell_li

Unregistered / Unconfirmed
GUEST, unregistred user!
ASP: have the use of Application.lock and Application.unlock.
Ido
n't know whether JSP: have the same use.
If you know,Could you tell me how to use it?
Thank you very much!
From a lovely girl.
 
在访问计数器中经常用到Application.lock.当某一程序用Application.lock后
其它程序就不能用Application对象.所以一般来讲,计数器在计数时往往先lock
后再unlock.
 
t1122:
Thank you for your answer.
but I have some difficulty to realize this following programme:
I want to input a number(The current number) and add all my input
numbers (The sum is:).
Could you try to run this pg?
/*
<HTML>
<HEAD>
<%@page language="java" import="java.sql.*" contentType="text/html;charset=x-sjis"%>
</HEAD>
<body>
<p><b>追加Data</b></p>
<%!
String num;
String nn;
String pp;
String mm;
String bb1;
int len;
int tt;
int n;
int m;
int bb;

%>
<%
m=0;
if(session.getAttribute("line")!=null){
Object o=session.getAttribute("line");
mm=(String)o;
m=Integer.parseInt(mm);
}

if(session.getAttribute("connect")=="First")
{
num=request.getParameter("textfield22");
if (num.length()==0){
out.println("error");
}
else
{
tt=Integer.parseInt(num);
bb=m+tt;
bb1=Integer.toString(bb);
out.println("The current num"+num);
out.println("The sum is:"+bb1);

session.setAttribute("line",bb1);

}
}%>

<table width="588" border="1">
<tr>
<td colspan="3"><span class="red10p12lb">※</span><span class="black10p12l">学部名を追加登録する場合は、必要な行数を入力してください。</span></td>
</tr>
<tr>
<form method="post" action="testsession2.jsp">
<td align="middle" colspan="3">
<div align="left"><span class="black10p12l">記入欄をさらに
<input name="textfield22" size="2" > 行追加します。</span>
<input type=submit Value=" " style="BACKGROUND-IMAGE: url(file://N:/llnewsyllabus/image/tuika.gif);
COLOR: silver;
DISPLAY: list-item;
VERTICAL-ALIGN: sub" id=submit1 name=submit1>
</div>
</td>
<%session.putValue("connect","First");
%>
</form>
</tr>
</table>

</BODY>
</HTML>
*/
This following pg runs right,but when I hit the "refresh button" the
session still works.That is the input item has no number,the sum add the before session number.That's not right.I just want to keep the sum not to change when hitting the "refresh button".
So I want to Application to control the pg.
Ido
n't know how to realize it.
Please give me some advise.
Thanks a lot!
 
/*The Pg Code:*/
《HTML》
《HEAD》
《%@page language="java" import="java.sql.*" contentType="text/html;charset=x-sjis"%》
《/HEAD》
《body》
《p》《b》追加Data《/b》《/p》
《%!
String num;
String nn;
String pp;
String mm;
String bb1;
int len;
int tt;
int n;
int m;
int bb;

%》
《%
m=0;
if(session.getAttribute("line")!=null){
Object o=session.getAttribute("line");
mm=(String)o;
m=Integer.parseInt(mm);
}

if(session.getAttribute("connect")=="First")
{
num=request.getParameter("textfield22");
if (num.length()==0){
out.println("error");
}
else
{
tt=Integer.parseInt(num);
bb=m+tt;
bb1=Integer.toString(bb);
out.println("The current num"+num);
out.println("The sum is:"+bb1);

session.setAttribute("line",bb1);

}
}%》

《table width="588" border="1"》
《tr》
《td colspan="3"》《span class="red10p12lb"》※《/span》《span class="black10p12l"》学部名を追加登録する場合は、必要な行数を入力してください。《/span》《/td》
《/tr》
《tr》
《form method="post" action="testsession2.jsp"》
《td align="middle" colspan="3"》
《div align="left"》《span class="black10p12l"》記入欄をさらに
《input name="textfield22" size="2" 》 行追加します。《/span》
《input type=submit Value=" " style="BACKGROUND-IMAGE: url(file://N:/llnewsyllabus/image/tuika.gif);
COLOR: silver;
DISPLAY: list-item;
VERTICAL-ALIGN: sub" id=submit1 name=submit1》
《/div》
《/td》
《%session.putValue("connect","First");
%》
《/form》
《/tr》
《/table》

《/BODY》
《/HTML》
 
我是用servlet完成的这个功能。比如下面的servlet类:
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
class Test extends HttpServlet {
int i;
public void init(...) throws ... {
i=0;
}
public voiddo
Get(...) throws ... {
...
i++;
out.println("i="+i);
}
}
这样,你刷新servlet页面的时候,就可以看到变动的i值了。
很不好意思,这个例子我没经过测试,如果错了的话,你可以用email联系我。
 
接受答案了.
 
顶部