java.lang.Runtime. . init, ( - BackEndServlet) doGet doPost.
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
String url = "http://localhost:8080"+config.getServletContext().getContextPath()+"/BackEndServlet";
System.out.println(url);
String os = System.getProperty("os.name").toLowerCase();
Runtime rt = Runtime.getRuntime();
try{
if (os.indexOf( "win" ) >= 0) {
rt.exec( "rundll32 url.dll,FileProtocolHandler " + url);
} else if (os.indexOf( "mac" ) >= 0) {
rt.exec( "open " + url);
} else if (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0) {
String[] browsers = {"epiphany", "firefox", "mozilla", "konqueror",
"netscape","opera","links","lynx"};
StringBuffer cmd = new StringBuffer();
for (int i=0; i<browsers.length; i++)
cmd.append( (i==0 ? "" : " || " ) + browsers[i] +" \"" + url + "\" ");
rt.exec(new String[] { "sh", "-c", cmd.toString() });
} else {
return;
}
}catch (Exception e){
return;
}
return;
}