Install a Web server with the green version of Tomcat and the green version of the JDK

Source: Internet
Author: User



    (1) Use the green version of the JDK to extract the D:\jdk1.6 to a directory.
   (2) Use the green version of Tomcat to extract to another directory D:\jdk1.6\tomcat5.5

    as long as the bat file D:\tomcat5.5\bin \catalina.bat, the
    configuration Java_home can be run.
    Add: Set Java_home= "D:\jdk1.6", so you can run it.

Test Tomcat, Access:   http://127.0.0.1:8080/, can open the page visited.
The
uses a simple voting system. http://127.0.0.1:8080/vote/
Voting system (please do not download, already encrypted)

There is a button on the mainform.jsp of the management interface that modifies the data, the link is isvisable.jsp, When you click Edit, you return to mainform.jsp. The
problem is: You cannot refresh mainform.jsp, it still displays the original data.

Therefore, a simple solution is used:
         on mainform.jsp, disable caching,
as follows:
<% Response.setheader ("Cache-control", "No-store");%>
<%response.setheader ("Pragma", "No-cache");%>
<%response.setdateheader ("Expires", 0);%>

<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache, must-revalidate" >
<meta http-equiv= "Expires" content= "Mon, Jan 1978 20:52:30 GMT" >

In the isvisable.jsp,

<%
int QuestionID;
int isvisable;
QuestionID = Integer.parseint (Request.getparameter ("QuestionID"));
Out.print (QuestionID);
sql = "Select isvisable from Questions where QuestionID =" +questionid;
rs = smt.executequery (SQL);
Out.println (RS);

while (Rs.next ())
{
isvisable = Rs.getint (1);
Out.println (isvisable);
if (isvisable==1)
{
Statement smttmp = Con.createstatement ();
sql = "Update Questions set isvisable = 0, IsOpen = 0, isopendetial = 0 where QuestionID =" +questionid;
Smttmp.executeupdate (SQL);
Response.sendredirect ("mainform.jsp"); Removed, cannot be returned directly, due to update the database, it takes time
}
else if (isvisable==0)
{
Statement smttmp = Con.createstatement ();
sql = "Update Questions set isvisable = 1, IsOpen = 0, isopendetial = 0 where QuestionID =" +questionid;
Smttmp.executeupdate (SQL);
Response.sendredirect ("mainform.jsp"); Removed, cannot be returned directly, due to update the database, it takes time.
}

}
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta http-equiv= "Refresh" content= "1;url= mainform.jsp" >//wait 1 seconds, automatically refresh to the main page.
<title>
Isvisable
</title>


Is there a good way?

The original as long as the normal close connection can be, feel is not so submitted, especially to close the connection,
Problem solved, it seems to be based on the code to write a program only, open the link, be sure to close.

<%
int QuestionID;
int isvisable;
QuestionID = Integer.parseint (Request.getparameter ("QuestionID"));
Out.print (QuestionID);
sql = "Select isvisable from Questions where QuestionID =" +questionid;
rs = smt.executequery (SQL);
Out.println (RS);

while (Rs.next ())
{
isvisable = Rs.getint (1);
Out.println (isvisable);
if (isvisable==1)
{
Statement smttmp = Con.createstatement ();
sql = "Update Questions set isvisable = 0, IsOpen = 0, isopendetial = 0 where QuestionID =" +questionid;
Smttmp.executeupdate (SQL);
if (smttmp! = null)
{
Smttmp.close ();
}
Response.sendredirect ("mainform.jsp");
}
else if (isvisable==0)
{
Statement smttmp = Con.createstatement ();
sql = "Update Questions set isvisable = 1, IsOpen = 0, isopendetial = 0 where QuestionID =" +questionid;
Smttmp.executeupdate (SQL);
if (smttmp! = null)
{
Smttmp.close ();
}
Response.sendredirect ("mainform.jsp");;
}

}

if (con! = null)
{
Con.close ();
}
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>
Isvisable
</title>

Install a Web server with the green version of Tomcat and the green version of the JDK

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.