April Benzine

Greenhorn
+ Follow
since Sep 23, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by April Benzine

Thank You
16 years ago
Integer accessCount = (Integer) session.getAttribute("accessCount");


(Integer) is casting. What is the purpose of this? Aren't you already saying that accessCount is of type Integer? When is it correct to use this?
16 years ago
Thank you for helping
16 years ago
I am trying to access a bean's property from a jsp. A servlet is used in the middle. when I try the getProperty I get this error and I don't know what it means:

Note: sun.tools.javac.Main has been deprecated.
c:\ServletExec\Servlets\pagecompile\_projFourJSP_xjsp.java:42: Variable 'bean' is already defined in this method.
Object bean = pageContext.findAttribute( "bean" );
^
1 error, 1 warning

Please help

Code for JSP:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>Project Four JSP</title>
<jsp:useBean id="bean"
class="java146.project4.ProjectFourServlet"
scope="application"/>
</head>
<body bgcolor = silver>
<center><h1>Search Results For Project Four</h1></center>
<table border = 2>
<th>
<tr>
<td>Empoyee ID </td>
<td>First Name </td>
<td>Middle Name </td>
<td>Last Name </td>
<td>SSN </td>
<td>Department </td>
<td>Room</td>
<td>Phone Ex.</td>
</tr>
</th>
<I><jsp:getProperty name="bean" property="employeeTable" /></I>
</table>



<A HREF="/">Home</A>
</body>
</html>
16 years ago
Hi all,
I am trying to execute a query in a servlet. I have a connection.

--a static html page--
The user clicks on a radio button for one of the following this is all in a form and the form works)
id
lastName
firstName
dept

Then there is a text box to enter in criteria(This works too)
Then they click submit and it takes them to my results.java page (this works)

---results.java---(servlet)
In my init method I have my employeeSearch object instantiated and loaded.
(this makes a connection and does a test query)- this works

???Now I have to run a query on the database. How do I do this?
I know this goes in my doGet method. Please help me.
Thank You
I don't think I explained this very well.
suedocode:
-use file to store number
-init method
-open history file and read data (just contains a number)
-private int historyNum
-public synchronized void writeNumToFile(){
-increment
-open file
-write to file
-close file
}
16 years ago
Hi all,
I can't figure out how do the code for displaying how many times my page has ever been accessed. here is my code I have so far. historyNum is an instance variable.

public synchronized void writeNumToFile() {
historyNum ++;
try {
in = new BufferedReader(new FileReader("c:\\projects\\src\\java146\\project3\\visitHistory.dat"));
} catch (FileNotFoundException fnfe) {
System.out.println("File not found.");
fnfe.printStackTrace();
} catch (IOException fnfe) {
System.out.println("Cannot read file.");
fnfe.printStackTrace();
}


}


Thank you!!
16 years ago
hi, i need to make a html table (this i know how to do) but i have to pass in the information from my proerties file that is in my util package. how do i import my own util package. any help is greatly appreciated.
16 years ago
JSP
Sorry it took so long to get back here, but that was exactly the problem. I forgot to import the package. I thought it was a lot harder than that. Thank you so much.
16 years ago
I have to make a multi threaded client/server connection. I also have get the information about the EmployeeSearch class from an emps.jar file that I have placed in one of my directories. It is a Access database and I have already added an ODBC data source(Microsoft Access Driver [*.mdb]). The location of this class is in my properties file, which has been passed into my program via the PropertiesManager.java in my util directory. The compiler cannot find the EmployeeSearch class, I get a "cannot resolve symbol". Help Please!!
javascript: x()
banghead
[ edited to add code tags -ds ]
[ October 27, 2004: Message edited by: Dirk Schreckmann ]
16 years ago
Those were just the specs of the project's class diagram
16 years ago
Everything compiles fine, but when I run it and enter in the full path name of the text file I get a java.lang.NullPointerException
16 years ago
Sorry, my main method is in another class called ProjectOneDriver. Here's the code for that:

public class ProjectOneDriver
{
/**
* The main program for the ProjectOneDriver class
*
*@param args The command line arguments
*@exception IOException Description of the Exception
*/
public static void main(String[] args) throws IOException {
if(args.length==2){
AnalyzeFile af = new AnalyzeFile();
af.runApp(args);
}
else{
System.out.println("You need to enter the full path of the file" );
}
}

}

Hope this is enough info
16 years ago
I have to pass in a text file from the command line to a class that reads it in, processes and counts its tokens then prints it out to a .dat file in my output directory. how do I connect what is entered in on the command line with the variable I have created in my class (it cannot be hard coded in my class)?

Here's my code:



[Edited to add UBB Code tags to make code reading easier - GB]

Please help
[ September 29, 2004: Message edited by: Gregg Bolinger ]
16 years ago
I have a directory structure set up. The C rojects\config> directory holds my project1.properties file. then in C rojects\src\java146\util> I have PropertiesManagement.java. This util package will be used in all my projects so I can't hardcode the name of my properties file in here. I need to pass in the properties file name and location useing either the constructor or set methods. Here is my code:

package java146.util;
import java.io.*;
import java.util.*;
/**
* Description of the Class
*
*@author AHobart
*@created September 23, 2004
*/
public class PropertiesManager {
private Properties props;
private String propertiesFileName;

/**
* Constructor for the PropertiesManager object
*/
public PropertiesManager() {

}
/**
* Gets the author attribute of the PropertiesManager object
*
*@return The author value
*/
public String getAuthor() {
return props.getProperty("author");
}
/**
* Gets the email attribute of the PropertiesManager object
*
*@return The email value
*/
public String getEmail() {
return props.getProperty("email");
}
/**
* Gets the course attribute of the PropertiesManager object
*
*@return The course value
*/
public String getCourse() {
return props.getProperty("course");
}
/**
* Gets the section attribute of the PropertiesManager object
*
*@return The section value
*/
public String getSection() {
return props.getProperty("section");
}
/**
* Gets the instructor attribute of the PropertiesManager object
*
*@return The instructor value
*/
public String getInstructor() {
return props.getProperty("instructor");
}
/**
* Gets the day attribute of the PropertiesManager object
*
*@return The day value
*/
public String getDay() {
return props.getProperty("day");
}
/**
* Gets the time attribute of the PropertiesManager object
*
*@return The time value
*/
public String getTime() {
return props.getProperty("time");
}
/**
* Gets the room attribute of the PropertiesManager object
*
*@return The room value
*/
public String getRoom() {
return props.getProperty("room");
}
/**
* Gets the property attribute of the PropertiesManager object
*
*@param key Description of the Parameter
*@return The property value
*/
public String getProperty(String key) {
return props.getProperty(key);
}
/**
* Description of the Method
*/
public void loadProps() {
props = new Properties();
try {
props.load(this.getClass().getResourceAsStream(propertiesFileName));
} catch (IOException ioe) {
System.out.println("Can't load the file: " + ioe);
ioe.printStackTrace();
return;
} catch (Exception e) {
System.out.println("Problem: " + e);
e.printStackTrace();
return;
}
}
}

Please Help me!!
16 years ago