?
Solved

Accesing a Java Bean from my JSP, in Tomcat-Apache

Posted on 2003-03-05
14
Medium Priority
?
425 Views
Last Modified: 2013-11-21
I have my application in folder
C:\Tomcat 4.1\webapps.
Under my service I have a bean in "abc" package. This is in folder
C:\Tomcat 4.1\webapps\wstk\WEB-INF\classes\abc\myjavaclass.

Now when I call a function from the class in my JSP(residing in C:\Tomcat 4.1\webapps\wstk\folder\) then the function is invoked twice every time. I have the entry
<jsp:useBean id='abc' scope='session' class='abc.clientclass' type="abc.clientclass"  /> in my JSPs. I then invoke it like abc.func1().

Can u suggest why the function is getting called twice.

Regds,
Nitesh
0
Comment
Question by:nxg912
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
14 Comments
 
LVL 3

Expert Comment

by:NetWize
ID: 8078234
sounds strange. could you paste some more code? (like extract from JSP, how you call it, how you tell that it is called twice)

Maybe it's just a logging problem. I once had my log4j.properties configured in a way that produced many rwsy for just one call (more than one category prints to Console logger for example)
0
 

Author Comment

by:nxg912
ID: 8080340
There is nothing different in the code

I have declared my bean in the jsp as:
<jsp:useBean id='abc' scope='session' class='abc.myclass' type="abc.myclass"  />

This is how I call the function.
Vector weight_data = abc.insertAlternativeWeight( criteriaId);

And the function in myclass is like

public static Boolean insertAlternativeWeight(Vector criteria_data)  throws Exception
     {            
          QName serviceQN = new QName("http://" + NQ, NQ + "Service" );
             QName portQN    = new QName("http://" + NQ, "data");
             Service service = new Service(new URL(wsdlURL), serviceQN );

             Call call       = (Call)service.createCall(portQN, "insertAlternativeWeight");
          System.out.println("Invoking the insertAlternativeWeight Service.");

          Boolean result =   (Boolean)call.invoke( new Object[] {criteria_data} );
          return result;
     }

Actually its a Web-Service that I am trying to call.

This System.out.println statement, gets printed twice on the tomcat screen

Can u give some details about this log4j file.

Thanx
Nitesh
0
 
LVL 3

Expert Comment

by:NetWize
ID: 8080492
that's really strange.

maybe you could insert a System.out around the call as well just to check that the whole JSP-Code is called twice?

Or could it be possible that your browser makes 2 calls to that jsp? (Frames?)

Log4J is a logging api from apache:

http://jakarta.apache.org/log4j 

it allows you to change the level of output by changing a configuration-file (no recompile to get rid of debug-statements...)
0
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

Author Comment

by:nxg912
ID: 8080720
The basic problem is that the whoole JSP is getting executed twice. Ihave tried putting the System.out call in the JSP and everything gets printed twice. There are no frames in the JSP.
0
 

Author Comment

by:nxg912
ID: 8080749
Also, it doesn't happen always. Some times it works fine and some times not.
0
 
LVL 3

Expert Comment

by:NetWize
ID: 8080782
that is really weird.

what browser are you using to call that page?

Does this happen to all jsps or just to that single one?

try creating a test.jsp:

<%
 System.out.println("TEST: " + System.currentTimeMillis());
%>
<html>
<body>
<h1>test</h1>
</body>
</html>

Is that printed twice as well?

Another thing to try:

insert short sleeps after the System.out's

try { Thread.sleep(50) } catch(Exception e){}

let's say you have

System.out.println("A");
System.out.println("B");
System.out.println("C");

on your page.

Do you see A B C A B C (sequential calls) or are the outputs mixed in a way (parallel calls) ?
0
 

Author Comment

by:nxg912
ID: 8080805
Also, it doesn't happen always. Some times it works fine and some times not.
0
 

Author Comment

by:nxg912
ID: 8080899
I have used both Iexplore and Netscape, both give same problem. This problem is going on for all JSPs.

Your test JSP is working fine, it always prints just once.

Putting the short sleeps the output is in mixed that is parallel calls.


0
 

Author Comment

by:nxg912
ID: 8080993
I have used both Iexplore and Netscape, both give same problem. This problem is going on for all JSPs.

Your test JSP is working fine, it always prints just once.

Putting the short sleeps the output is in mixed that is parallel calls.


0
 

Author Comment

by:nxg912
ID: 8081031
I have used both Iexplore and Netscape, both give same problem. This problem is going on for all JSPs.

Your test JSP is working fine, it always prints just once.

Putting the short sleeps the output is in mixed that is parallel calls.


0
 

Author Comment

by:nxg912
ID: 8081134
I find the mistake.
Actually the buttons I declare were submit buttons that why it was calling the JSPs twice

Thanx for ur help.
How can I award points. I don't know the procedure. Do let me know.

Thanx Agian
NItesh
0
 
LVL 3

Expert Comment

by:NetWize
ID: 8081263
You accept an answer (link is in the header of each answer to the right: Accept Comment As Answer

then you have to assign a grade to the answer (A to D) specifiing how much the answer helped you.

That's it.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11741771
PAQed, with points refunded (100)

Netminder
Site Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question