Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Harsha Vardhan Madiraju

Greenhorn
+ Follow
since Dec 19, 2003
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 Harsha Vardhan Madiraju

Hi all,

I have written a simple "HelloWorld" servlet with the following web.xml file



<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>HelloWorldServlet</servlet-class>
</servlet>
<</web-app>

Im using Tomcat 4.1.29. what is the url i have to give in ie to execute this servlet
I have tried the following but invain

http://localhost:8080/scwcd/HelloWorldServlet
(scwcd is folder name under webapps where the servlet class is present)

http://localhost:8080/scwcd/servlet/HelloWorldServlet


But when i add the following to web.xml
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/HelloWorldServlet</url-pattern>
</servlet-mapping>
and give the url as http://localhost:8080/scwcd/HelloWorldServlet
im able to execute the servlet

My question/doubt is it mandatory to give servlet mapping tag to execute a servlet ???
this is weblogic-ejb-jar.xml.............
<!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 7.0.0 EJB//EN' 'http://www.bea.com/servers/wls700/dtd/weblogic-ejb-jar.dtd'>

<!-- Generated XML! -->
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>DeptEJB2</ejb-name>
<entity-descriptor>
<pool>
</pool>
<entity-cache>
</entity-cache>
<persistence>
<persistence-use>
<type-identifier>WebLogic_CMP_RDBMS</type-identifier>
<type-version>7.0</type-version>
<type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
</persistence-use>
</persistence>
<entity-clustering>
</entity-clustering>
</entity-descriptor>
<transaction-descriptor>
</transaction-descriptor>
<jndi-name>DeptEJB2</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
this is ejb-jar.xml.............
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<!-- Generated XML! -->
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>DeptEJB2</ejb-name>
<home>DeptHome</home>
<remote>Dept</remote>
<ejb-class>DeptEJB</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<abstract-schema-name>DeptEJB2</abstract-schema-name>
<cmp-field>
<field-name>id</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>DeptEJB2</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
this is weblogic-cmp-rdbms-jar.xml............

<!DOCTYPE weblogic-rdbms-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 7.0.0 EJB RDBMS Persistence//EN' 'http://www.bea.com/servers/wls700/dtd/weblogic-rdbms20-persistence-700.dtd'>
<!-- Generated XML! -->
<weblogic-rdbms-jar>
<weblogic-rdbms-bean>
<ejb-name>DeptEJB2</ejb-name>
<data-source-name>MyDataSource</data-source-name>
<table-map>
<table-name>dept</table-name>
<field-map>
<cmp-field>id</cmp-field>
<dbms-column>dept_id</dbms-column>
</field-map>
<field-map>
<cmp-field>name</cmp-field>
<dbms-column>dept_name</dbms-column>
</field-map>
</table-map>
</weblogic-rdbms-bean>
<create-default-dbms-tables>True</create-default-dbms-tables>
</weblogic-rdbms-jar>
hi all,
i am unable to deploy my entity bean it says" unable to locate the datasource, check ur JNDI name....."

i did configure the connection pool and the datasource at the Weblogic console with correct jndi name, also i also checked that same datsource which is configured at console, is used in deployement descriptor file .
Pls help me, thanx in advance
harsha
Hi,
i'd like to thank the entire javaranch team for putting up a great site like this. Although i did not participate much in the forum but regularly i used to see the reviews of diff code examples. It indeed helped me alot.
Keep the good work going
harsha
17 years ago
hi all,
Im happy to say that i cleared SCJP 1.4 exam with 91%. Reg my preparation for this exam, first i started with Java Complete Reference, which is a good book for a guy who doesn't know much abt Java/OOPS. Then after completing the first part of that book, i continued with Complete Certification Study Guide by R&H. This book is very helpful in exam point of view. Then at last, after covering all the concepts i started taking mock exams, which are given JavaRanch Mock Exams list.
In Mock exams , Marcus Green exams are almost at the same level as the real exam , and people say that the score what u get in this exam is close to ur actual score (and it happened with me!). Next, Khalid Mughal exams at this link http://www.danchisholm.net/dec20/guide/index.html are tough but we can learn a lot of concepts. I used these set of exams as a learning tool rather than a testing tool.
On the whole it a great learning experience for me.
harsha
17 years ago
Hi murali,
Pls send me a copy or link of material
Hi sridhar,
int[][] ar2=new int[1][3];//Line1
System.out.println(ar2[1].length);//Line2

Array Indexes Start from 0 not 1,so there is no ar2[1] since in line 1 u declared an array of int[1][3]
Line 2 can be replaced by
System.out.pritnln(ar2[0].length);//prints 3
hi sriram,
Thanx man for correcting me!
hi sridhar,
The Rule is
A Super Reference Variable can refer a Subclass Object.
ie
SuperClass s = new SubClass(); //Subclass extends SuperClass is valid
the otherway isn't valid ie SubClass sb = new SuperClass()
Comin to Object Ref Casting..
Consider this Scenario

Class Fruit
{
}
Class Citrus extends Fruit
{
}
Class Orange extends Citrus
{
}
Class Lemon extends Citrus
{
}
Class Test
{
public static void main(String args[])
{
Fruit f;
Citrus c;
Orange o,or;
Lemon l;
o=new Orange();
//Object created, call it as O1
c=o;//perfectly valid going by rule, c now refers to O1
f=o; //perfectly valid Its nothing but c=o; followed f=c;
// f now refers to O1
l=o; //not valid, since l is not Superclass of o, this is called sidecasting
l=(Lemon)o;
//This is casting, in this case both sides are of type Lemon hence no compile time error, But There will be a Runtime Exception because both classes are incompatible

or = (Orange)f; //No compile time error as explained above
// There will be no Runtime Exception also, It's like this...
f is containing a reference to O1 (Orange Object), u r trying to assign that reference to o1 which is also of type Orange.
I hope that sounds logically correct.

}
}
hi vicken,
Oops!
Im running on JDK 1.4.1_02!
Hi Vicken,
The code posted by Vineela is giving compile time error!
(Running on JDK 1.4.2)
U try to copy paste this below code and compile it. This code also generates the same error

class Test
{
void get(int i)
{
System.out.println("Hsssi");
}
void get(float i)
{
System.out.println("saa");
}
}
class Test1 extends Test
{
void get(float x)
{
System.out.println("AAAA");
}
public static void main(String args[])
{
Test1 t = new Test1();
t.get(33);
}
}

Anyone pls explain this...
Thanx in advance
hi all,
Can anyone explain me how the below comparison is true or returns true
Math . round ( Integer . MIN_VALUE - 6.5f ) == Integer . MIN_VALUE
Thanx in advance
Hi sridhar,

suppose we r trying to find out the following
--> -3 >> 1
--> -3 << 1
--> -3 >>> 1
Note all the numbers are taken as integers (32 bits) not bytes or shorts
First see how to obtain -3's binary representation:
-3 binary code is obtained by taking 2'complement of 3's binary code.
2's complement means inverting all bits and then adding 1
Binary representation of 3: 00000000000000000000000000000011
Inverting all the bits we get: 11111111111111111111111111111100
lets add 1 to it: +
00000000000000000000000000000001
---------------------------------
11111111111111111111111111111101
---------------------------------
So The binary form of -3 is :11111111111111111111111111111101

so now lets see -3 << 1:
It means left shift -3 by one bit.
ie 11111111111111111111111111111101 << 1 = 11111111111111111111111111111010
--------------------------------
Observe that in the above -3 representation, left most bit is discarded and at the right most a '0' is appended, to get the underlined representation.
So the answer is 11111111111111111111111111111010
clearly the first bit is 1, so its a negative no. In order to obtain its magnitude we have to take 2's complement of it.
So follows the above said steps
something like this...
11111111111111111111111111111010
After Inversion
00000000000000000000000000000101
Adding 1 + 00000000000000000000000000000001
--------------------------------
00000000000000000000000000000101 = 6 in decimal form
--------------------------------
Hence its clear that answer or result has magnitude 6 and since its a negative no. Its -6 the required answer
Hence -3<<1 = -6
Similarly u can calculate for -3>>1 and -3>>>1
hi vineela,
The O/P starts from 3 itself!
Its hard to see it on the system,
so give as
for(int i = 3; ; i++){
System.out.println(i);
if(i>30)
break;
}