JSP programming progress bar design example (4)

Source: Internet
Author: User

Iii. Task progress


The status. jsp page displays the execution status of the task to the user using an HTML progress bar. First, status. jsp uses the <jsp: useBean> tag to obtain the Bean object created on the start. jsp page:


<Jsp: useBean id = "task" scope = "session"
Class = "test. barBean. TaskBean"/>


To timely reflect the task execution progress, status. jsp will be automatically refreshed. The JavaScript code setTimeout ("location = status. jsp", 1000) refresh the page every 1000 milliseconds and Request status. jsp again without user intervention.


<HTML>


<HEAD>
<TITLE> JSP progress bar </TITLE>
<% If (task. isRunning () {%>
<Script language = "JavaScript">
SetTimeout ("location = status. jsp", 1000 );
</SCRIPT>
<% }%>
</HEAD>


<ODY>


The progress bar is actually an HTML table containing 10 units-each representing the overall 10% progress of the task.


<H1 ALIGN = "CENTER"> JSP progress bar </H1>


<H2 ALIGN = "CENTER">
Result: <% = task. getResult () %> <BR>
<% Int percent = task. getPercent (); %>
<% = Percent %> %
</H2>


<Table width = "60%" ALIGN = "CENTER"
BORDER = 1 CELLPADDING = 0 CELLSPACING = 2>
<TR>
<% For (int I = 10; I <= percent; I ++ = 10) {%>
<Td width = "10%" BGCOLOR = "#000080"> & nbsp; </TD>
<% }%>
<% For (int I = 100; I> percent; I-= 10) {%>
<Td width = "10%"> & nbsp; </TD>
<% }%>
</TR>
</TABLE>
 
Task execution is in the following statuses: Execution in progress, completed, not started, and stopped:


<Table width = "100%" BORDER = 0 CELLPADDING = 0 CELLSPACING = 0>
<TR>
<Td align = "CENTER">
<% If (task. isRunning () {%>
Executing
<%} Else {%>
<% If (task. isCompleted () {%>
Complete
<%} Else if (! Task. isStarted () {%>
Not started
<%} Else {%>
Stopped
<% }%>
<% }%>
</TD>
</TR>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.