Adwin Lorance

Greenhorn
+ Follow
since May 31, 2010
Merit badge: grant badges
For More
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 Adwin Lorance

Hi

Recently I came up with a problem of interacting with a Payment Gateway. The problem I faced was to maintain the session between our site and the merchant site.

Any suggestions on how it can be achieved? The merchant site has given a URL to which I need to post my form. They have also asked for a landing page(in our site) where they will send the response after making the payment. As soon as I post my request , the session object of my JSP is destroyed; and when they send the response back, a new session object is created.

Any suggestions are welcome to solve this issue.
13 years ago
Ok , let me share what I think ...

There are 2 types of exception
Checked and Unchecked Exception.

Checked Exception : Object of type Exception or its sub class , except the runtime exception.
Unchecked Exception : Object of Type Runtime Exception and its sub type.

Compiler forces you to handle/declare any checked exceptions.

Compiler does not force you to handle/declare any unchecked exceptions , as you cannot predict whether an unchecked exception can occur.

But still , you can handle it.

Error - It is unchecked , as you cannot predict when an Error can occur.
Also , you cannot handle it.
13 years ago
True .. As Ninad says , Container is responsible to create Threads and give each request to a new Thread. Or else pick from a pool of servlet instances and let it handle a request.

What did you want to do in a multi threaded environment ?
13 years ago
Hii

I was trying to consume a Web service exposed in the internet . I made a Webservice Client in Eclipse by giving the wsdl path of the service. But when I am trying to access the service , I am getting the following exception.

[INFO] Unable to sendViaPost to url[http://www.webservicex.net/globalweather.asmx]
java.net.NoRouteToHostException: No route to host: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:125)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:371)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:209)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at net.webservicex.www.GlobalWeatherStub.GetCitiesByCountry(GlobalWeatherStub.java:200)
at net.webservicex.www.WeatherClient.main(WeatherClient.java:28)


Any idea about the problem?

Thanks in advance.

Adwin
13 years ago
Serialization is definitely there in the SCJP 6 exam.

Cheers

------------------------------------------------------------------------------------------------------------------------------------------------
SCJP 6 80%
This belongs to the Model i.e. the POJO that you will write.
13 years ago
Hii .. just wanted to share why a method local inner class can access final variables...

As you must be knowing that when we compile a class having a method local inner class , the compiler makes 2 class files.
e.g. outer.class and outer$inner.class

Now imagine , if you could pass non final variables to a function inside the inner class. How will the JVM pass a variable from one class to a function in another class.
To solve this problem , the JVM makes a requirement that the developer mark the variable as FINAL.

How does it solve the problem?

when you mark a variable as final in the outer class , the compiler places a hidden variable (e.g. val$var ) in the compiled inner class file.
The value of this hidden variable and the final variable declared in the outer class will be same. And as it is final , it cannot change at the runtime. Also , the final variables has to be assigned before the compilation.

So problem solved.
I hope I was clear.
Hi .. you can create a WAR file using the JAR utility available. The only pre requisite is that you need to prepare a proper deployment folder structure and a proper deployment descriptor.

The command is as follows - " jar -cvf MyWarFileName.war".
Execute this command from the command line after going to the appropriate folder.

Whether there is way to only include .class files?

Well , whatever you keep in the folder on which you are running the JAR utility , will be included in the WAR file.

For e.g. The normal folder structure will be like below.


Place the package structure in the classes folder. And the Deployment Descriptor directly under the WEB-INF folder.

Thanks

[BPS: Added to code tags to dir tree to show indents.]
13 years ago
That is correct , Thread implements Runnable .. But it is always a good practice to implement the interface Runnable than extending Thread , as it gives you flexibility to inherit from other classes.. Anyways , it wont make a difference if you extend from Thread or implement Runnable ..

Adwin
13 years ago