How the JSP calls the Linux shell

Source: Internet
Author: User
Tags jboss

Often run into the operating department to clear the cache, and the cache has always been a problem, the old in front of the computer is not a way to think of a method, by accessing a JSP page automatically clear cache

<%@ page language= "java" import= "java.io.*" pageencoding= "UTF-8"%>

<%

String path = Request.getcontextpath ();

String basepath = request.getscheme () + "://"

+ request.getservername () + ":" + request.getserverport ()

+ path + "/";

%>

<title>shell</title>

<body>

<%

String Cmds = "monitor.sh";

try {

Process process;

Process = Runtime.getruntime (). EXEC ("sh/opt/wzx/monitor.sh");

InputStreamReader ir = new InputStreamReader (process

. getInputStream ());

LineNumberReader input = new LineNumberReader (IR);

String Line;

Process.waitfor ();

while (line = Input.readline ())!= null) {

Out.print (line);

Out.print ("<br/>");

}

if (input!=null) {

Input.close ();

}

catch (Exception e) {

E.printstacktrace ();

}

%>

</body>

test.sh Script Content

echo ' Flush_all ' | NC 192.168.10.73 11211

Put the script under jboss/server/default/deploy/jboss-web.deployer/root.war/to access the

Related Article

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.