I am using an Apache Tomcat 5.5 web server (which I'm very new to) on a Windows Server.
I have written a class called HRCapture with a class within it called HR:
package edu.usf.cse.uguard;
import java.util.*;
public class HRCapture
{
class HR
{
int heartRate;
Date timeStamp;
HR (int hr, Date ts)
{
heartRate = hr;
timeStamp = ts;
}
HR()
{
}
}
public HRCapture()
{
user = "";
activity = "";
typeOfTravel = "";
}
public void newHR(int hr, Date ts)
{
hrArray.add( new HR(hr, ts));
}
public String user, activity, typeOfTravel;
private ArrayList<HR> hrArray = new ArrayList<HR>();
double longitude = 0.0;
double latitude = 0.0;
}
I compiled it with javac (which gave me "HRCapture.class" and "HRCapture$HR.class") and I put it in: "C:\Program Files\Apache Software Foundatioin\Tomcat5.5\webapps\ROOT\WEB-INF\classes\edu\usf\cse\uguard".
In another file, I'm trying to initialize a variable of type HRCapture:
<%@ page language="java" %>
<%@ page import="edu.usf.cse.uguard.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="org.json.JSONArray" %>
<%@ page import="java.util.*" %>
<%@ page import="com.google.gson.*" %>
<%@ page import="com.google.gson.Gson" %>
<%
HRCapture hrc = new HRCapture();
if (request.getParameter("id") == null)
{
}
else
{
String input = request.getParameter("id");
Gson gson = new Gson();
try
{
//hrc = gson.fromJson(input , HRCapture.class);
//out.println(input);
out.println("Success");
}
catch (JsonSyntaxException ex)
{
}
catch (JsonParseException ex)
{
}
catch (Exception e)
{
}
}
%>
However, when I go to the webpage, I get an error saying that
"The constructor HRCapture() is not visible" even though I have the constructor set to public within the HRCapture class. This error occurs on line where I have HRCapture hrc = new HRCapture();
I have tried both: <%@ page import="edu.usf.cse.uguard.*" %> and <%@ page import="edu.usf.cse.uguard.HRCapture" %> and I get the same result...
Is my import statement incorrect? Did I screw up the constructor some how?
Any help would be appreciated!