Kavita Bopardikar

Greenhorn
+ Follow
since Oct 16, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Kavita Bopardikar

I am using tomcat 4.1 server.
I have a servlet named LoginServlet & have defined it in the deployment descriptor as follows:
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>Login.*</url-pattern>
</servlet-mapping>

When I invoke it as: http://localhost:8080/appname/Login.ac
it gives error HTTP-404 URL not found.
But, if i define the url-pattern as *.login & invoke it as
http://localhost:8080/appname/ac.login
it takes me to the corresponding page.

Why does the * behave differently before the . & after the .

If i have an entry like *.* will this work? I am unable to understand why * behaves differently?
20 years ago
Thanks Sanjay
Its working now. I had another option of doing it using jpub - Jpublisher an Oracle utility which will create a java source & class file of the Oracle object.
But, this thing you mentioned about getting an object array & its attributes is just right.
Thanks a lot.
Hi!
Following is java code & also the oracle procedure. I am using JDBC thin client.
I am passing an IN OUT parameter which is registered. Since it is of type oracle object, i am registering as Types.STRUCT. But, it fails:
I am getting error - catch : java.lang.ClassCastException: oracle.sql.STRUCT
Java code:
import java.io.*;
import java.sql.*;
public class PassObject
{
String TaskName;
int TaskID;
PassObject(int id, String nm)
{
TaskID = id;
TaskName = nm;
}
PassObject()
{
TaskID = -1;
TaskName = null;
}
public static void main(String args[])
{
PassObject po = new PassObject(1,"Kav");
po = po.setDetails();
System.out.println("Task ID : " + po.TaskID);
System.out.println("Task Name : " + po.TaskName);
}

public PassObject setDetails()
{
Connection conn = null;
ConnectionPool mypool = null;
ResultSet rs = null;
Statement st = null;
String query = null;
ResultSetMetaData rsmd = null;
PassObject nw = new PassObject();
CallableStatement cs = null;
nw = this;
try
{
mypool = ConnectionPool.CreatePool("jdbc racle:thin:@nims:1521:nimd07",
"nims",
"sminful",
"",
1,
1);
conn = mypool.getConnection();
//CallableStatement cs = conn.prepareCall("{call kb_pr(?)}");
System.out.println("Here");
//cs.setObject(1,nw,Types.STRUCT);
System.out.println("Here 2");
cs = conn.prepareCall("BEGIN NIMS.kb_pr(?); END;");
cs.registerOutParameter(1, Types.STRUCT, "KB_COMP");
cs.executeQuery();
Struct p = (Struct) cs.getObject(1);
nw = (PassObject) p;
//System.out.println("Return Value = " + p);
System.out.println("Return Value = " + nw.TaskID);
cs.close();
}
catch(Exception e)
{
System.out.println("catch : " + e);
}
finally
{
mypool.returnConnection(conn);
return nw;
}
}
}

STORED PROCEDURE:
procedure kb_pr(fn_comp out kb_comp)
is
BEGIN
fn_comp := kb_comp('Changed',10);
end;
ORACLE OBJECT STRUCTURE
type kb_comp as object
(Name VARCHAR2(30),
ID NUMBER)

Please Help...
Thanks.
Thanks for your replies folks !
I have found a solution to the problem.
The one mentioned by Thomas Paul will work. But, there's a slight catch in this one. There's always a chance that one user may save without making changes. In that case, the update date/time will be changed & another user who has actually changed the values will get a message that the record is changed & will have to requery the record only to find that there are no changes to it & his work of having made changes is futile.
The solution i have in mind is - before commiting the changes to the table, compare the current contents of that record with the ones sent by user. If there is even one change, then flash a message that the record has been changed & requery to see latest one. The advantage of this that the earlier problem of incorrect message of the record being changed is not displayed & genuine changes are committed & secondly, if at all user insists on getting a list of fields changed, well, it can be generated.
So folks, thanks once again for your answers. I hope my reply has also given you some more ideas about this thing. In case you have any more ideas about this one, please post your replies. I am looking for an efficient method. If one exists, it can be implemented.
How can i ensure that one record is not updated by more than one user at the same time.
e.g. suppose i have a product table with fields product ID, product name, rate.
One user has taken up record having product id = 5 for updating the rate.
Another user has taken up the same record with product id = 5 for updating the product name.
How can I ensure that the commit for change of product rate is not overwritten by the commit for change of product name ?
How can I decide when to use non-visual beans & normal java class.
I am developing an application which requires me to check the database for the latest query results. Should i go for javabeans or will a java class be good enough.
What exactly is the criteria to decide whether to use non-visual beans or a java class ?
Hello Matt,
See if this makes things clear :
1. A local variable becomes eligible for gc when it goes out of scope.
A local variable is alive only in the method in which it is declared. Hence, once the method is over, the local variable sor of "dies", means it goes out of scope. Once it goes out of scope, it is eligible for gc.
2. When a local variable is set to null, it means that it no longer has any references to it. So, it is eligible for being gc'd. If the gc routine runs at the time when the local variable has no reference, it is gc'd.
In short, a local variable is ready for gc whenever
a. it goes out of scope
or
b. all references to it are set to null
whichever is earlier.
Got it ???

Originally posted by Matt DeLacey:
It has been said that local variables become eligible for garbage collection when they go out of scope. This sort of implies that there aren't eligible before then, but what happens if they are set to null before they go out of scope. Would they then be eligible for gc BEFORE they went out of scope?
Matt


Couldn't resist it, so compiled & tried it.
At first glance, i found out that the code will give compilation errors, since the statements after "return" are unreacheable code. Hence, first of all, the return statement must be the last statement.
Secondly, I think since this is a function call, functions will be evaluated in the order in which they are called. Hence, considering that following is the revised code, the output after the function calls will be fx1 fx2 fx3.
class EvaluationOrder
{
public static void main(String args[])
{
EvaluationOrder eo = new EvaluationOrder();
int y = eo.fx1()+ eo.fx2() * eo.fx3();
// int z = 4 + 4 * 3;
// System.out.println(z);
}
int fx1() { System.out.println("fx1"); return 1; }
int fx2() { System.out.println("fx2"); return 2; }
int fx3() { System.out.println("fx3"); return 3; }
}
However, the operator precedence will be considered for the commented statement where z is assigned some value of an expression.
Hey, thanks a lot.
That certainly helps. Because so far in all the books I have read, its mentioned that GC is run as the lowest priority thread. But, I never thought that there could be scenarios where it may differ.
Yes, the other thing about being "eligible" for garbage collection is also true. An object need not be gc'd, but it could be ready for being gc'd.
Thanks for sharing your thoughts about this one.

Originally posted by Ajith Kallambella:

Good notes Kavitha. !!
Sorry for being picky, but I would just like to comment on two of your statements -
[b]First of all, garbage collection is vendor specific & is run as the lowest priority thread by the JVM (which is again vendor specific). Since its run as the lowest priority thread, one can't predict when gc will be run. It is normally run when there are no more threads ready for execution.

This is usually true, however because of the vendor dependency, it is better not to make any assumptions. There may be implementations of VM where GC is made a priority thread - VMs running on hardware where memory is very expensive, hand-held devices and PDAs for example. So let's just say GC is vendor specific and you cannot assume anything about the priority of the GC thread.

Second point to remember is automatic variables are gc'd when they go out of scope.
I would like to correct this statement and say, automatic variables become eligible for garbage collection when they go out of scope.

You can be assured you will not get very tricky questions about GC in the exam. The typical questions will be identifying when the object becomes eligible for garbage collection
Just my two cents worth ....
Ajith[/B]


Hi everybody,
Thanks a lot for ur replies.
I think I understood it somewhat.
Thanks once again!

Originally posted by Amit Saini:
Hi all,
i=expr;
-the value of the expr is assigned to i;
-now the assignment operator is at the last of precedence table
therefore whatever be the expression, the value of that expression will be assigned to i, as the last step of evaluation.
-now let us dissect the expression>
i=0;
i=i++;
the value of i comes out to be 0 as we all know.
this is how it all works.
++ has higher precedence.
i++ will increment the value of i but u see since it is a post increment operator the initial value of i i.e 0 is somehow magically stored in the expression..
i=(i++) as i=(0); //note i is incremented to 1
now , the final evaluation is:
i=0; // even at this moment i was 1;
but after the exec. of the above statement i becomes 0;
i hope it is clear


Hello Amit,
I will try to explain the garbage collection thing:
First of all, garbage collection is vendor specific & is run as the lowest priority thread by the JVM (which is again vendor specific).
Since its run as the lowest priority thread, one can't predict when gc will be run. It is normally run when there are no more threads ready for execution.
The JVM keeps track of all the objects that have references & all that don't. So, whenever the gc is run (can't say when it is run), it will check out all those objects having no references & clear the memory used up by these objects.
Secondly, one can explicitly set the reference of an object to null, as follows...
Assume s1, s2 to be member variables :
1. String s1 = "Java Forum";
2. String s2 = s1;
3. s1 = null;
4. s2 = null
In step 1, a String s1 is created & allocated some memory to store the literal "Java Forum".
In step 2, another String s2 is created & it points to the same location where s1 points to. Hence, we say s2 contains the value "Java Forum".
In step 3, the reference s1 is set to null, that means s1 now DOES NOT point to the string "Java Forum". However, the reference s2 is still pointing to "Java Forum" or any other string.
In step 4, the reference s2 is set to null, that means s2 now DOES NOT point to the string "Java Forum" or any other string.
Hence, the strings s1 & s2 can be gc'd. In fact, the memory location where "Java Forum" is stored does not contain any references, hence that memory is freed.
Second point to remember is automatic variables are gc'd when they go out of scope.
One more important thing to note is that if a thread is created in a function or say in the constructor of an object & the start method is called, the JVM notes that it is a live thread & the thread is not gc'd until its run method is over. (When a thread's run method is over, the thread becomes dead & can be gc'd).
I hope its clear now.
Anybody would like to add something to this ?
Hello,
I was earlier registered as Kav Bop. But, because of the restrictions regarding names, now i have registered myself as Kavita Bopardikar. Is there any way to unregister my earlier id ? I am unable to find the option anywhere.
Kindly help.
24 years ago