Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-03-05
14
Medium Priority
?
426 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
  • 8
  • 4
13 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
[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

 

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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

581 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