Run Java class from JSP
This is how my main java class looks like
public class Main {
public static void main(String[] args) throws Exception {
XmlParser b = new XmlParser();
ServiceController sl = new ServiceController();
Pipeline2 objPipeline2 = new Pipeline2();
objPipeline2.main(args);
b.parseXML();
sl.callServiceByDomain();
}
public void function1() throws Exception {
System.out.println("hello");
}
Here is the run.jsp file where I want to run the main function
<%@ page import="java.io.*" %>
<%@ page import="main.Main" %>
<HTML>
<HEAD>
<TITLE>Enter Email over here</TITLE>
</HEAD>
<BODY>
<jsp:useBean id="link" scope="application" class = "main.Main" />
<%Main r=new Main();
Main.main(null);%>
</BODY>
</HTML>
I cannot run it if I run the run.jsp file where as if I was trying to run function1 from jsp instead of main ... it works. please help me in this regard
+3
source to share
1 answer