This is similar to the problems at java parameter in jsp:include and https://stackoverflow.com/questions/6677981/eclipse-project-from-ant-build-file-for-a-java-web-project-on-svn-doesnt-import
I am looking to execute a Java file (run.java) from a JSP file (response.jsp) and return its output to the JSP file.
I am using
Mac OSX 10.6.8, Apache Tomcat 6.0.16, Java1.6.0_29, Eclipse IDE Indigo,
I have a JSP Web App deployed in Tomcat that searches an XML content repository and returns results to the user.
I have been asked to include a Java API that crawls predefined websites using the same query. This has to stay separate from the Web App
I need to send the users Query to the Java API and return the content to the JSP WebAp. Can anyone give me a few hits about posting a query to an external Java API?
The JSP file already calls other .jsp files in the same WebAp e.g.
<%@ include file="siteheader.jsp" %>
<jsp:include page="<%= session.getAttribute(\"device\") + \"header.jsp\"%>">
<jsp:param name="title" value="Response" />
</jsp:include>
I have tried the below and more then a few other variations to get it to at least connect to the external java file but cant crack it.
<%@ include file="/Users/me/Documents/workspace/Slicer/src/slicer/Run.java" %>
I keep getting the tomcat error, File "Macintosh HD/Users/me/Documents/workspace/Slicer/src/slicer/Run.java" not found
Any suggests or help is much appreciated
B
Please look at BalusC's solution at
How do I programmatically compile and instantiate a Java class?
For testing, copy and paste the following JSP. I hope BalusC doesn't mind that I changed his code.
It's not correct to include a Java Source File in a JSP page. What you should do is execute the java program (as a Class or a JAR file) from a server component, like a Servlet (you can do it from a JSP page, but such stuff should be done in the Controller layer).