Hari Haran

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

Recent posts by Hari Haran

Hi,
I also had the same problem.
But I had a workaround and placed the classes under $CATALINA_HOME/common/classes.
Now it is working fine.
But I still dont understand why it doesnt work if I put in my application folder like
/WEB-INF/classes of your web application
If anybody can find a solution pls.post it.

But according to Tomcat documentation this is what they had to say:
"
Therefore, from the perspective of a web application, class or resource loading looks in the following repositories, in this order:
/WEB-INF/classes of your web application
/WEB-INF/lib/*.jar of your web application
Bootstrap classes of your JVM
System class loader classses (described above)
$CATALINA_HOME/common/classes
$CATALINA_HOME/common/lib/*.jar
$CATALINA_HOME/classes
$CATALINA_HOME/lib/*.jar
"
23 years ago
JSP
Hi Arun,
I too struggled for this and I have somehow managed to do it with some difficulty.
So use it and save ur time.I am sending the code.
In my case : The country and state are stored in SQL.
mgr.getListSorted("Country_Key")will fetch
Country Key : IN
Country Value : India
mgr.getSub_List("State") will fetch the following from the table
State Key :IN-TN
State Value :Tamilnadu
<tr>
<td width="30%"><b>Country key *</b></td>
<td width="70%">
<!-------------------------------Country-State Code Starts Here -------------------------->
<%

//Get the Country List
TreeMap tm_Country = mgr.getListSorted("Country_Key");
Collection col_Country = tm_Country.values();
Set set_Country = tm_Country.keySet();
Iterator it_Country_Elements= col_Country.iterator();
Iterator it_Country_Keys= set_Country.iterator();
//Get the State List
Hashtable ht_State = mgr.getSub_List("State");
Enumeration enum_State_Elements = ht_State.elements();
Enumeration enum_State_Keys = ht_State.keys();
String key="";
String val="";
String statekey="";
String statevalue="";
String countrykey="";
%>

<select name="cmb_Country" onChange="val()">
<option value = "-1" selected>--Select a Country--</option>

<%

while(it_Country_Elements.hasNext() && it_Country_Keys.hasNext())
{
key = (String)it_Country_Keys.next();
val = (String)it_Country_Elements.next();
%>
<option value = "<%out.println(val);%>" ><%out.println(key);%></option>

<%
}
%>
</select>

<script language="javascript">
var Country_Code = new Array();
<%

while(it_Country_Keys.hasNext())
{
int ctr=0;
countrykey = (String)it_Country_Keys.next();
%>
Country_Code[<%=ctr%>]="<%=countrykey%>";
<%
ctr++;
}
%>
var State_Code = new Array();
var State_Desc = new Array();
var State_Code_Actual = new Array();
<%
int i=0;
String str_State_Code = null;
while(enum_State_Elements.hasMoreElements() && enum_State_Keys.hasMoreElements())
{
statekey = (String)enum_State_Keys.nextElement();
statevalue = (String)enum_State_Elements.nextElement();
StringTokenizer st = new StringTokenizer(statekey,"-");
while (st.hasMoreTokens())
{
str_State_Code = st.nextToken();
}
str_State_Code= str_State_Code.trim();
System.out.println(str_State_Code);
%>
State_Code[<%=i%>]="<%=statekey%>";
State_Desc[<%=i%>]="<%=statevalue%>";
State_Code_Actual[<%=i%>]="<%=str_State_Code%>";

<%
i++;
}
%>
</script>

<script language="JavaScript">
function val()
{

while(document.frm_Address_Create.cmb_State.options.length)
{
document.frm_Address_Create.cmb_State.options[0] = null;

}
document.frm_Address_Create.cmb_State.options[0] = new Option("Select a State","-1")
var country_value = document.frm_Address_Create.cmb_Country.value;
country_value = country_value.substring(0,2);
var k=1;

for(var l=0; l < State_Code.length;l++)
{
State_Code[l] = State_Code[l].substring(0,2);
if(country_value == State_Code[l])
{
document.frm_Address_Create.cmb_State.options[k] = new Option(State_Desc[l],State_Code_Actual[l]);
k++;
}
}
}
</script>

<!-------------------------------Country-State Code Ends Here -------------------------->
</td>
</tr>
<tr>
<td width="30%"><b>State *</b></td>
<td width="70%">

<select name="cmb_State">
<option value = "-1" selected>Select a State</option>
</select>
</td>
</tr>
Regards,
Hari
"Happiness is Perfect only when Shared"
23 years ago
JSP
Hi All,
I was using a Hash Table to get List of values and Keys from Database and populate combo boxes in JSP.
The values were not sorted because of this.So I am now using a TreeMap for the same.
The following is the code I use.
=================================
Iterator it_Industry_Elements = null;
Iterator it_Industry_Keys= null;
TreeMap tm_Industry = mgr.getListSorted("Industry");
Collection col_Industry = tm_Industry.values();
Set set_Industry = tm_Industry.keySet();
Iterator it_Industry_Elements= col_Industry.iterator();
Iterator it_Industry_Keys= set_Industry.iterator();
String str_Industry_Keys = null;
String str_Industry_Elements = null;
while (it_Industry_Elements.hasNext() && it_Industry_Keys.hasNext())
{

str_Industry_Keys = (String)it_Industry_Keys.next();

str_Industry_Elements = (String)it_Industry_Elements.next();

%>

<option value="<%out.println(str_Industry_Keys);%>">
<%out.println(str_Industry_Elements);%>
</option>
<%
}// end while
%>
</select>
But I get the following error in JSP
=====================================
500 Internal Server Error
Java Server Page Translation Error
Error during compilation :
D:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_Previous__Employment__Create.java:481: Class java.util.TreeMap not found in type declaration.
TreeMap tm_Industry = null;
^
D:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_Previous__Employment__Create.java:482: Class pagecompile.jsp.Collection not found in type declaration.
Collection col_Industry = null;
^
D:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_Previous__Employment__Create.java:483: Class pagecompile.jsp.Set not found in type declaration.
Set set_Industry = null;
^
D:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_Previous__Employment__Create.java:485: Class pagecompile.jsp.Iterator not found in type declaration.
Iterator it_Industry_Elements = null;
^
D:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_Previous__Employment__Create.java:486: Class pagecompile.jsp.Iterator not found in type declaration.
Iterator it_Industry_Keys= null;
^
5 errors

Note :I have included java.util.* also as u can see in the following line.
<%@ page language="java" import="java.sql.*,java.util.*,javax.mail.*,javax.mail.internet.*,com.ess.business.*,com.ess.manager.*"%>
Any help ASAP would be appreciated.

Hari
23 years ago
JSP
Thanx Carl I will try that.
Hari
23 years ago
JSP
Hi All,
I am fetching a list of all the Countries and their keys from the database.
The select query is sorted by country name alphabetically.
But when I use the following code the result is an unsorted list of countries.
Any help is appreciated ASAP.
Following is the code sample:
erdManager e = new erdManager();
Hashtable ht = e.getList("Country_Key");

Enumeration enum1 = ht.elements();
Enumeration enum2 = ht.keys();
String str1;
String str2;
while(enum1.hasMoreElements() && enum2.hasMoreElements())
{
str1 = (String)enum1.nextElement();
str2 = (String)enum2.nextElement();
System.out.println(str1+"-"str2);
}
23 years ago
JSP
Thanx,
Now when I put it in session scope.
It is working.
Hari
23 years ago
JSP
Hi all,
I am getting users educational data from the jsp page.
He can input more than 1 educational qualification.Only after he says it is enough, I take all these data into the database.
Meanwhile,I am storing all the educational details he supplies in a vector.But when the page refreshes only the latest details are there(Suppose he had entered 2 degrees)only the latest one is visible.The rest are not there...
I tried initializing the vector size also...
What could be the problem...
Any help ASAP would be appreciated
:roll:
23 years ago
JSP
Hi Donald,
If I understand ur Question right this is what u want.
Eg:
U display the ID Name and Address which is a result of a Query.
Now when u click on the Id ,probably u want that id's some other details(say if it is a custome, u want his balance details).Right...
If this was ur question then u can pass the ID appended with the Query string.
Proceed in the following way..
Run a loop through the result set
Display the id as follows
<tr>
<td><a href="Balance.jsp?Id = <%out.println(str_Id);%>"> <%out.println(str_Id);%>
</href>
</td>
<td><%out.println(str_Name);%></td>
<td><%out.println(str_Address);%></td>
</tr>
</tr>
Now when u click on the ID the corresponding jsp,page will be called.
There u can call your beans get method using this id as a parameter.
Hope it helps...
:roll:
[ February 05, 2002: Message edited by: Hari Haran ]
23 years ago
JSP
Hi Nancy,
I have given a sample code for validating and storing values in session.

<%
String login = request.getParameter("login");
String passwd = request.getParameter("passwd");


try
{
if(cl_connection.validate(login,passwd)==true)
{

session.putValue("Login",login);
response.sendRedirect("http://..../somepage.jsp");

}
else
{
response.sendRedirect("http://.../login.jsp);
}
}
catch(Exception e)
{
out.println("Exception :"+e.toString());
}
%>

In subsequent pages just use
String str_Login =(String)session.getValue("Login");
to retrieve the Login.
U can put as many values in session which can be available throughout the user session.
When the user logs off use session.invalidate();
to clear all the values from the session.
Hope this solves ur problem.

"Life is too Wonderful to be Spent worrying"
23 years ago
JSP
I am also facing the same problem.If somebody comes out with some solution soon,would be helpful
23 years ago
JSP
Hi all,
I am facing a problem in "Retrieving Decimal data from SQL"
I tried using BigDecimal,float and double.
Any help ASAP would be appreciated.
Thanks in Advance..
Hari
Hi Guys,
We have to code JSP pages which will work even if cookies is disabled.I am using EncodeUrl and it is working.

Eg:
===
String EncodeUrlModify = response.encodeUrl("modify.jsp?MenuOption=2&SubMenuOption=4");
document.frm.action="<%=EncodeUrlModify%>";
<a href="<%=EncodeUrlModify%>">

But,In the places where I use sendredirect, I used
response.encodeRedirectURL()
But it doesn't seem to work properly.
Please help me out.
Regards,
Hari
24 years ago
Check out this site. http://www.jguru.com/jguru/faq/view.jsp?EID=1045
There is a clear explanation and a simple example.
Hope this helps!!
Happy Coding!!
24 years ago
I tried working on ur problem and it seems to create no probs.
Here is the sample code.
I used a javawebserver.
Place the compiled bean class file under the \classes\sunexamples\beans folder
Jsp under \public_html folder
Happy Coding!!!

Bean
=====
package sunexamples.beans;
import java.util.*;
public class myclass
{
public Vector v=new Vector();
public Vector getVector()
{
try
{
v.add("Java");
v.add("Ranch");
v.add("Servlets and JSps");
return v;
}
catch(Exception e)
{
return null;
}
}
}
Jsp
====
<%@ page language="java" import="java.util.*" %>
<jsp:useBean id="mc" scope="session" class="sunexamples.beans.myclass" />
<html>
<body>
<%
try
{
Vector vtr=mc.getVector();
String s;
out.println(vtr);
if(vtr!=null)
{
Enumeration enum= vtr.elements();
out.println("I am here");
while (enum.hasMoreElements())
{
s= (String) enum.nextElement();
out.println(s);
}
}
else
{
out.println("Vector is Null");
}
}
catch(Exception e)
{
out.println("Error"+e);
}
%>
</body>
</html>
24 years ago
Is it possible to call a java class from a PLSQl block?
If so how do I do it?

24 years ago