Siyaa Hoffman

Greenhorn
+ Follow
since Jan 15, 2004
Merit badge: grant badges
For More
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 Siyaa Hoffman

Using stored procedure is a good idea. It can return multiple resultsets, so that you do not need to go back to the database again and again.

Just make the connection one time and run all the SQLs, get the resultsets and use them as and when you need.

Also, if the same results are going to be used in concurrent requests, you can store the query results in a Java Bean object with a proper scope.
19 years ago
If your filter is not initializing successfully, then I don't think that the context would be even successfully loaded....not sure about OC4J...but tomcat behaves that way. It would not even let you load the web application context successfully if the filter cannot be initialized.
19 years ago
Hi Vali,

Try this code. This creates a deadlock between the two threads.

public class TestThreadSync implements Runnable
{
String A = new String("Siyaa1");
String B = new String("Siyaa2");

public static void main(String[] args)
{
TestThreadSync mainClass = new TestThreadSync();
Thread t1 = new Thread(mainClass);
Thread t2 = new Thread(mainClass);
t1.setName("T1");
t2.setName("T2");
t1.start();
t2.start();
}


public void run()
{
try{
if(Thread.currentThread().getName().equals("T1"))
{
System.out.println("Thread T1 launched");
synchronized(A)
{
System.out.println("Thread T1 got lock on A");
Thread.sleep(10000);

synchronized(B){
System.out.println("T1 managed both");
}
}
}

if(Thread.currentThread().getName().equals("T2"))
{
System.out.println("Thread T2 launched");
synchronized(B)
{
System.out.println("Thread T2 got lock on B");
Thread.sleep(10000);

synchronized(A){
System.out.println("T2 managed both");
}
}
}

}
catch(Exception e)
{
System.out.println("Exception - "+e.getMessage());
}
}




}

The output that I see is -

C:\Test>java TestThreadSync
Thread T1 launched
Thread T1 got lock on A
Thread T2 launched
Thread T2 got lock on B


And the program just hangs there. This is what I expected it to do when entered in a deadlock situation.
I think you should consider using LinkedList in Java Collection Framework in Java2 instead of Vector.

It has methods like addFirst(),addLast() etc. which none other container has.
19 years ago
Few things that I see wrong here -

1. I do not think you can define buffer as buffer="5". You have to specify buffer="5kb"

2. Your servlet class does not extend HttpServlet which is essential.

3. To write the String out in the servlet, you should take the PrintWriter using the API call response.getWriter()

4. You are closing the response stream in the servlet, so you would not be able to see "Jim2"


-Siyaa
19 years ago
JSP
Is there some way that the results of your long query can be cached locally ?

In that case, you can load the servlet on start-up and the data from the long query can be cached locally so that the subsequent requests read it from the cache and do not take that long.

Also, see the following URL -
http://www.javaranch.com/newsletter/200403/AsynchronousProcessingFromServlets.html
[ June 04, 2004: Message edited by: Siyaa Hoffman ]
19 years ago
Hi Hai,

I think all the value elements are case sensitive unless the container is taking care of ignoring cases for the fixed element values.

Tomcat definitely needs exact cases to work ...not sure about other application servers.
19 years ago
JSP
Hi Sureshvasan,

In the next servlet, if the next servlet is invoked in the same session, you would be able to just do session.getAttribute(attributeName) to get the value. You do not need to create any new session in that servlet.

But if the next servlet is not invoked in the same session, you cannot access the attribute defined in the session scope. If that is a possibility, you need to see which scope would suit you. The available scopes are -

request
session
application
19 years ago
Hi Praveen,

I have seen in the recent application servers, I think those having servlet engines for Servlet 2.3 onwards, you cannot invoke the servlet just by placing it in the classes and then using the url .../servlet/...

Try using servlet-mapping in the web.xml and then reload the web application.
19 years ago
Hi Sebastian,

In your servlet code, in the doGet() or doPost() method, you can get the session from the request object -

request.getSession() would give you the HttpSession. Then you can use the same API session.setAttribute() in the servlet code to set up the session level attribute.
Exactly what you are doing in the JSP.
[ June 01, 2004: Message edited by: Siyaa Hoffman ]
19 years ago
For your specific XML, try this xsl conversion -

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="text"/>

<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="header">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="subject">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="body">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="footer">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>

</xsl:stylesheet>

It should create a text file with these contents -


Hello!

Re: XSLT Help!!

Can you guys help me out???

Thanks
Hi Eric,

I think you need to use the following -

<xsl:for-each select="/Player/Stat">
<xsl:value-of select="@Type"/>
</xsl:for-each>

So, here for every /Player/Stat, you print the Type attribute value.
[ May 26, 2004: Message edited by: Siyaa Hoffman ]
Hi,

I wanted to know that is it possible to use SAX parser and get the data in a comment node...when I say node I actually mean the data in the element -

<!--this data using SAX -->

I know in DOM, there is a comment node and you can get that data.
How would I get that data using SAX ?

Thanks,
Siyaa
I think it makes perfect sense. Also, I tested with 200 and the compiler gives error.
Thanks,
Siyaa
19 years ago
Why the following code works -
class MyClass
{
public static void main(String []args)
{
final int i = 100;
byte b = i;
System.out.println(b);
}
}
whereas the following code gives proper compilation error -
class MyClass
{
public static void main(String []args)
{
int i = 100;
byte b = i;
System.out.println(b);
}
}
19 years ago