Cyril Sadasivan

Greenhorn
+ Follow
since Jul 17, 2012
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
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Cyril Sadasivan

Hi Rohit,

I did ping the server machine. But I see the IP address has changed.

G:\client>ping 120.61.112.250

Pinging 120.61.112.250 with 32 bytes of data:

Reply from 120.61.112.250: bytes=32 time<1ms TTL=254
Reply from 120.61.112.250: bytes=32 time<1ms TTL=254
Reply from 120.61.112.250: bytes=32 time<1ms TTL=254
Reply from 120.61.112.250: bytes=32 time<1ms TTL=254

Ping statistics for 120.61.112.250:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

But there was no luck with the Java program
7 years ago
I have just started trying out RMI..
I have the Server class and Client class on different machines. rmiregistry was started on Server machine. properties were set using jndi.properties files at server and client

for the below Java code :

service:


remote interface :


server:

properties file at server:
java.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
java.naming.provider.url=rmi://localhost:1099

client:

properties file at client:
java.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
java.naming.provider.url=rmi://120.61.40.49:1099

i get the below error when i run the Client class:

javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectExce
ption: Connection refused to host: 120.61.40.49; nested exception is:
java.net.ConnectException: Connection timed out: connect]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at Client.main(Client.java:6)
Caused by: java.rmi.ConnectException: Connection refused to host: 120.61.40.49;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
... 4 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
... 9 more


Can anyone suggest what i am doing wrong?
7 years ago
Thanks a lot for the response Frits. Actually when I restarted tomcat, everything was all set!
But I have a different problem here..
This time I have got the below code in web.xml for the webapp "mapping":

and I just have "testPage.jsp" in the context root for the webapp.
was thinking that if I use the request "http://localhost:8080/mapping/test", tomcat would append "page.jsp".
The resulting request "http://localhost:8080/mapping/test/page.jsp"; is mapped to "/testPage.jsp" in the DD.
So I think I could access "testPage.jsp" that way.

But it isn't working. I get a 404 error.

Can you tell me if I am missing something? The "test" directory is non-existent. Is that what is wrong? I did restart tomcat this time
I have got the below code in web.xml for the webapp "mapping":

Also have "page.jsp" in the context root for the webapp.
But I am not able to access "page.jsp" with "http://localhost:8080/mapping".
Any help on this?
When is the "type" element for "attribute" required in the TLD for tag handlers?
I tried passing objects using EL expressions as tag attribute for both simple and classic tag handlers without the "type" element in TLD. And the container passed the object of the appropriate datatype to the attribute setter method.

Any help on the topic is welcome.
7 years ago
JSP
When is the "type" element for "attribute" required in the TLD for tag handlers?
I tried passing objects using EL expressions as tag attribute for both simple and classic tag handlers without the "type" element in TLD. And the container passed the object of the appropriate datatype to the attribute setter method.

Any help on the topic is welcome.
What happens when <c:set> is used as below ?

-What kind of object is stored in the attribute "userLevel"?
-How do we access members of "userLevel" individually?
yeah that's right but the point is

if a static member variable can be accessed with object of enclosing class(objectOfEnclosingClass.staticVariable),
why can't static member class be accessed with object of enclosing class(objectOfEnclosingClass.staticNestedClass)?


The commented line of code doesn't compile.
I thought it should have because static members can be accessed through objects too.
Any justifications?

rohit sahai wrote:Hi Mala

can you please tell me why the class does not comile ,if assignment is allowed


public class Breaker {
static String o = "";
public static void main(String[] args) {
z:
o = o + 2;
for(int x = 3; x < 8; x++) {
if(x==4) break;
if(x==6) break z;
o = o + x;
}
}
}


Rohit, the problem is not with the assignment statement. The label 'z' is applicable only for the statement "o=o+2;"

is same as

The "break z;" statement is within the for loop which is an unlabeled block.
For labeled break statements to work, the "break label" should appear within a block labeled with the particular label.
The code should be rewritten as follows:
7 years ago
congrats pritish..excellent score!

even i'm preparing for OCPJP6.
a queston: 'K&B' means 'SCJP study guide by Kathy and Bert' right?
that's all what is needed for the preparation right?
8 years ago
These are the points i gathered
-When an inner class is extended by code, outside the enclosing class, the extending class 'must write' a constructor which calls it's super class constructor through an instance of the outer class of the super class.
-The default contructor provided by the extended inner class will have 'super()' which will fail since super() in this case can be called only as an invocation on an outer class object.

just to make sure i understood, i wrote the below program.

Output:
8 years ago
i am sorry, i'm not much familiar with the forum..didn't know topics could get locked..
anyways thanks for all the help guys..
just going through all your replies on both the posts
8 years ago

Henry Wong wrote:


Henry



Thanks a lot Henry.
I got the concept..but i am not familiar with the idea of calling super() on a different object
8 years ago

For the above code, the compile time error generated is :
No enclosing instance of type Main is available due to some intermediate constructor invocation.
Does this error indicate that there is some other way to extend an inner class by code outside the top level class?
Can someone help by explaining the error statement?