Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Bala Krishniah

Ranch Hand
+ Follow
since Dec 14, 2000
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 Bala Krishniah

Which is the preferred collection class to use for storing database ResultSets?
I have multiple columns in the result set, and I combine them into their own data structure for each row. Which is the best Collection class to store the objects??
Why would you say its incorrect. Could you please explain.
And the reason I am using the above logic is....
I was reading the database and storing the data, storing is a class object and storing those objects in a Vector and was always returning a Vector from my getBusinessObject() method...
CODE]
Collection getBusinessObject(){}
[/CODE]
But later on, I wanted to return two sets of vector objects from a the getBusinessObject() method. So I thought of putting the vectors in a Hashtable and return it, but couldn't since the return type extected is Collection. I could have added two vectors and returned a single vector...
but then I only have to depend on the position of the object in a vector.
Hence I thought of chaning the return type of getBusinessObject() to Object, so that I can return any type.
Please comment.
18 years ago
The return type of the getBusinessObjects() is 'Object', but I am returning the java.util.Collection, sometimes Hashtable...
Is this a good practice??
18 years ago
I dint realize that there's a separate section for applets. I'll post the question there.
I used the HTMLConverter and converterd my HTML. But still I am getting the same error...
18 years ago
I am trying to run an applet which makes a database connection.
I'm using jdk1.2.2, a local Oracle 8.1.7 for unix and the oracle
thin driver found in classes111.zip.
Although my classpath points to the file classes111.zip, I got the
ClassNotFoundException when running the applet.
The same setup (path, classpath, jdk1.2.2, oracle 8.1.7) works fine with
all the other standalone java applications.
What is wrong with the applet ?
My html code:
<applet archive="classes12.zip"
code="applet_main.class">

The exact error message is :
# Verifier error oracle/jdbc/driver/OracleConnection.initialize(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Loracle/jdbc/dbaccess/DBAccess;Ljava/util/Hashtable V: Cannot find class java/util/Map
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleConnection
at java.lang.ClassLoader.resolveClass(Compiled Code)
at java.lang.ClassLoader.loadClassInternal(Compiled Code)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(Compiled Code)
at oracle.jdbc.driver.OracleDriver.connect(Compiled Code)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(Compiled Code)
at app_applet_main12.execSQL(Compiled Code)
at app_applet_main12.init(Compiled Code)
* at netscape.applet.DerivedAppletFrame$InitAppletEvent.dispatch(Compiled Code)
at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
at java.awt.EventDispatchThread.run(Compiled Code)
at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled Code)
Thanks a lot for any help!!
18 years ago
I know how to update the bean using setProperty. But that updates just one javaBean object.
<jsp:useBean id="SearchForm" class="SearchForm" scope="request">
<jsp:setProperty name="SearchForm" property="*"/>
</jsp:useBean>
But if I have a array of javaBeans, can I use the same way to update the array..
<jsp:useBean id="searchForm" class="SearchForm" scope="request">
<jsp:setProperty name="SearchForm" property="*"/>
</jsp:useBean>
<% SubSearchForm[] myBean = searchForm.getSubSearchForms(); %>
When the user updates the myBean array, will the above setProperty takes care updating the myBean array?
18 years ago
JSP
Yes, but how do I loop through the data in the Servlet...
ie say in my JSP output is:
______________________________
Length width Description
______________________________
2 3 description1
2 4 description2
3 5 description3
6 4 description4
Lets say the user changes some of the vaues in the above table, how should I access each of the above row in the Servlet.
I should be able to put the values of the first row in myBean[0], 2nd row in myBean[1]...so on.
Ho do I do that? Thanks...
18 years ago
JSP
I forgot to mention, the user is allowed to enter a new rows too....
18 years ago
JSP
In my sevlets I make a databse call and am storing each row of the resultset in my JavaBean class. ie
myBean[0] - 1st row
mybean[1] - 2nd row
:
:
so on

I am sending the array of beans to JSP. And in JSP I display the data in a table

<jsp:useBean id="bean" class="com.property.MyBean">
<%
//I am getting the array of beans somehow here and lets think that myBean is that array %>
//Display the data here
:
for(int i=0; i<myBean.length; i++)
{
<tr>
<td><input type="text" id="length" value= <%=mybean[i].getLength()%> </td>
<td><input type="text" id="width" value= <%=mybean[i].getWidth()%> </td>
<td><input type="text" id="length" value= <%=mybean[i].getDescription()%> </td>
</tr>
}
So the JSP display a table with 3 colums and n rows.
The user is allowd to make changes to the data and when he hits ok, I have to get the updated data from the JSP, back to the servlet.
How do I do that...
Please give a suggestion.
Thanks
18 years ago
JSP
Thanks for the reply Michael.
I do not know anything about sockets. This my first little code I can say regarding Sockets. So please bear with me if my questions are silly.
I was thinking if the application crashes...and when you try to run the application again, it wont run since the port is still in use and was not released gracefully by the previous application.
In that case I have an option to run the application with the input parameter 'CLOSE'.
So if the application receives the parameter 'CLOSE', I check the socket object for 'null' if not then I call the close method on it.
ServerSocket listenerSocket;
:
:
if(args.length != 0)
try
{
if( args[0].equals("CLOSE"))
{
if( listenerSocket != null)
listenerSocket.close();
}
}
catch(Bind.....)
{
}
try
{
listenerSocket = new ServerSocket(11111);
}
catch(java.net.BindException nbe)
{
System.out.println("Already an instance running 1" );
System.exit(1);
}

Will that work. Will the next instance can catch hold of the socket instance.
Thanks for help!!
I have an console application and I need to make sure I have just one instance of the application running at any given point of time. So, I am using a serversocket connection
to check whether the application is running or not.
I am using a port 1111 and create a serversocket.
try
{
listenerSocket = new ServerSocket(11111);
}
catch(java.net.BindException nbe)
{
System.out.println("Already an instance running 1" );
System.exit(1);
}
First instancd runs. When you try to run another instance...since the port is occupied, it will exit.
But my question is, what is the application crashes. Will the socket gets closed??
If not, how do I close?
Help...Thanks
In my XML, each element has, say 10 attributes.....but I want to print only some of them. How do I do that...
I do not want to say...
<xsl:value-of select="../@attrib1"/>
<xsl:value-of select="../@attrib2"/>
:
I want to be able to filter out saying something like
<xsl:if test!="attrib1|attrib2">
<xsl:value-of select="@attrib1"/>
</xsl:if>
My xml:
<?xml version="1.0"?>
<catalog>
<cd title="Empire Burlesque" artist="Bob Dylan" country="USA"
company="Columbia" price="10.90" year="1985"
</cd>
.
.
.
</catalog>
I want to print only the values of the following attributes
artist, Country, company.
This is just an example....actually I have something like 20 attributes but I need to print only some of them.
Thanks in advance.
I have three different XML files and the corresponding XSLT stylesheets.
WHen I access the XML file from a database(it will be one of the three format), I have to apply a corresponding Stylesheet to it.
Is there a way to identify which XML file I have accesses currently. I am using apache's Xalan for processing.
I was thinking I have to use DOM or SAX, read the first elelemt...and based on that associate the correspoding XSLT file to it.
I'm I right?? Or is there another way of doing it.
Thanks
Hi I have one more question...
I have three different XML files and the corresponding XSLT stylesheets.
WHen I access the XML file from a database(it will be one of the three format), I have to apply a corresponding Stylesheet to it.
Is there a way to identify which XML file I have accesses currently. I am using apache's Xalan for processing.
I was thinking I have to use DOM, read the first elelemt...and based on that associate the correspoding XSLT file to it.
I'm I right?? Or is there another way of doing it.
Thanks
Thanks a lot Mapraputa Is!!
That worked beautifully!!