(More JNI woes...)
When I try to comply this code
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class HacerOperacionesConJNI
*/
public class HacerOperacionesConJNI extends HttpServlet
{
private static final long serialVersionUID = 1L;
private native double operaciones(double a,double b,String op);
public HacerOperacionesConJNI()
{
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String num1=request.getParameter("num1");
String num2=request.getParameter("num2");
String op=request.getParameter("op");
double res;
res=operaciones(Integer.parseInt(num1),Integer.parseInt(num2),op);
out.println("<HTML>");
out.println(" <HEAD><TITLE>Resultado</TITLE></HEAD>");
out.println(" <BODY>");
out.println("El resultado entre " +num1+" y "+num2+" utilizando el operador " + op + " es " + res);
out.println(" </BODY>");
out.println(" </HTML>");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String num1=request.getParameter("num1");
String num2=request.getParameter("num2");
String op=request.getParameter("op");
double res;
res=operaciones(Integer.parseInt(num1),Integer.parseInt(num2),op);
out.println("<HTML>");
out.println(" <HEAD><TITLE>Resultado</TITLE></HEAD>");
out.println(" <BODY>");
out.println("El resultado entre " +num1+" y "+num2+" utilizando el operador " + op + " es " + res);
out.println(" </BODY>");
out.println(" </HTML>");
}
static
{
System.loadLibrary("HacerOperacionesConJNI");
}
}
to produce a .class file, this error pops up:
HacerOperacionesConJNI.java:6: package javax.servlet does not exist
import javax.servlet.ServletException;
^
HacerOperacionesConJNI.java:7: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
^
HacerOperacionesConJNI.java:8: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
^
HacerOperacionesConJNI.java:9: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
HacerOperacionesConJNI.java:14: cannot find symbol
symbol: class HttpServlet
public class HacerOperacionesConJNI extends HttpServlet
^
HacerOperacionesConJNI.java:25: cannot find symbol
symbol : class HttpServletRequest
location: class HacerOperacionesConJNI
protected void doGet(HttpServletRequest request, HttpServletResponse res
ponse) throws ServletException, IOException
^
HacerOperacionesConJNI.java:25: cannot find symbol
symbol : class HttpServletResponse
location: class HacerOperacionesConJNI
protected void doGet(HttpServletRequest request, HttpServletResponse res
ponse) throws ServletException, IOException
^
HacerOperacionesConJNI.java:25: cannot find symbol
symbol : class ServletException
location: class HacerOperacionesConJNI
protected void doGet(HttpServletRequest request, HttpServletResponse res
ponse) throws ServletException, IOException^
HacerOperacionesConJNI.java:45: cannot find symbol
symbol : class HttpServletRequest
location: class HacerOperacionesConJNI
protected void doPost(HttpServletRequest request, HttpServletResponse re
sponse) throws ServletException, IOException
^
HacerOperacionesConJNI.java:45: cannot find symbol
symbol : class HttpServletResponse
location: class HacerOperacionesConJNI
protected void doPost(HttpServletRequest request, HttpServletResponse re
sponse) throws ServletException, IOException
^
HacerOperacionesConJNI.java:45: cannot find symbol
symbol : class ServletException
location: class HacerOperacionesConJNI
protected void doPost(HttpServletRequest request, HttpServletResponse re
sponse) throws ServletException, IOException^
11 errors
I try using the .class generated in WEB-INF (which is generated when I launch the deployment) but it still fails anyhow. Any tips? Thanks