aspose file tools*
The moose likes Servlets and the fly likes Clarify Mystery in JSP! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Clarify Mystery in JSP!" Watch "Clarify Mystery in JSP!" New topic
Author

Clarify Mystery in JSP!

Kris N
Greenhorn

Joined: Jan 02, 2001
Posts: 4
Hi all,
I am trying to call function from Class. First time it worked okay. Then I changed function name and did respective changes in JSP, it did not work. Please Clarify this.
Here is my JSP script:
======================
<%@ page language="java" %>
<html>
<head>
<title>Hello World - Example </title>
</head>
<body bgcolor=white>
<jsp:useBean id="Tot" scope='session' class="AddNum.SumNum" type="AddNum.SumNum" />
<jsp:setProperty name="Tot" property="*" />

<font face=arial color=red size=4><b>Display From The Bean</b></font>
<br><br>

<% int sum = 0;
sum = Tot.addNum(4,5);
out.println("Sum = " + sum);
%>

<br><br>
<font face=arial color=red size=4><b>End...</b></font>
</body>
</html>

Here is my Class:
==================
package AddNum;
public class SumNum {
int S=0;

public SumNum()
{
}
public int addNum(int a, int b)
{
S = a + b;
return S;
}
}
Thanks in advance
Kris
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Why are you using this tag:
<jsp:setProperty name="Tot" property="*" />
when the class does not have any setXXX methods?
It is hard to debug JSP if you don't have an error page designated. Setting an error page goes in your page directive:
<%@page errorPage="whoops.jsp"
Where whoops.jsp has isErrorPage="true" in the page directive - on that page you will have a default variable named exception that you can examine. Here is the whoops.jsp I used in my book as an example, where there was specific treatment for a NumberFormatException and general treatment for all others.
<HTML>
<HEAD>
<TITLE>Database Testing Entry</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<FONT FACE=VERDANA>
<H2 ALIGN=CENTER>
Shift Operator Demo Error
</H2><BR>
<%@ page language="java" isErrorPage="true" %>
<% if( exception instanceof NumberFormatException ){
%> Only numeric characters may be entered.<br>
<% } else { %>
<%= exception %>
<% } %>
</form>
</BODY>
</HTML>
Bill

------------------
author of:
vikas sahni
Greenhorn

Joined: Jan 01, 2001
Posts: 7
hi,
the reason may be that the bean's class must have been cached,
therefore whatever changes u are making in your bean is not taking effect..u can confirm it by placing the same method in the JSP file(which was there in the earlier bean and now not there),if it would run implies problem is of caching..then change the name of the bean and it would definitely work but remember for first time only.
vikas
Kris N
Greenhorn

Joined: Jan 02, 2001
Posts: 4
That is the problem Vikas. If I change anything in Bean, the effect is not taking place in the JSP. If I reboot the system and start Java Web Server,then it is working fine. How Can we overcome this 'CACHE' problem.
Anybody help me.
Thanks
Kris
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
I don't know of any Java servlet engine that checks every possible class file for changes before working on a request. Some will reload the servlet class if it has changed.
You are better off restarting the servlet engine every time you make a change - time consuming but safe.
Bill
------------------
author of:
Kris N
Greenhorn

Joined: Jan 02, 2001
Posts: 4
Thanks William Brogden for your reply. If we have to reboot the system for every small change , then it is very time consuming especially at the Development stage.
Is it depends on Server?. Because I am using Java Web Server 2.0.
Is the same problem with TomCat?. If anybody knows ,help me.
Thanks
Kris
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"Kris N",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
You certainly don't have to reboot the system, just stop the server and then start it again. That only takes a few seconds with Tomcat or JRun on my system - I suppose it could be worse if your application does a lot of database initialization.
Bill
eric moon
Ranch Hand

Joined: Nov 26, 2000
Posts: 133
I put tomcat startup and tomcat shutdown in my start menu, so it's extremely quick.
e


<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>"Those who cast the votes decide nothing. Those who count the<BR>votes decide<BR>everything." <BR> -Joseph Stalin<HR></BLOCKQUOTE>
Kris N
Greenhorn

Joined: Jan 02, 2001
Posts: 4
Thank you all for your responses.
Yes , Frank will follow rules.
Regards
Nirmala

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Clarify Mystery in JSP!