M
Mark F
For some reason I'm getting an NPE at this line:
fis = new FileInputStream(HitCountFilter.HITS_FILENAME);
HITS_FILENAME is a static variable that is set to "C:\\hits.ser"
Counter is a simple object with a funcion that is self-explanatory. It
implements serializable.
Here is the code:
public void init(FilterConfig fc) throws ServletException {
this.filterConfig = fc;
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(HitCountFilter.HITS_FILENAME);
}
catch (FileNotFoundException ex) {
...
}
catch (NullPointerException npe) {
...
}
try {
if (fis != null) {
ois = new ObjectInputStream(fis);
count = (Counter) ois.readObject();
}
else {
count = new Counter(0);
}
}
catch (ClassNotFoundException ex2) {
...
}
catch (IOException ex2) {
...
}
finally {
try {
ois.close();
fis.close();
}
catch (IOException ex3) {
...
}
}
}
fis = new FileInputStream(HitCountFilter.HITS_FILENAME);
HITS_FILENAME is a static variable that is set to "C:\\hits.ser"
Counter is a simple object with a funcion that is self-explanatory. It
implements serializable.
Here is the code:
public void init(FilterConfig fc) throws ServletException {
this.filterConfig = fc;
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(HitCountFilter.HITS_FILENAME);
}
catch (FileNotFoundException ex) {
...
}
catch (NullPointerException npe) {
...
}
try {
if (fis != null) {
ois = new ObjectInputStream(fis);
count = (Counter) ois.readObject();
}
else {
count = new Counter(0);
}
}
catch (ClassNotFoundException ex2) {
...
}
catch (IOException ex2) {
...
}
finally {
try {
ois.close();
fis.close();
}
catch (IOException ex3) {
...
}
}
}