madura shantha

Greenhorn
+ Follow
since Jun 04, 2008
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 madura shantha

Hi Sebastian,

Twisty (int i){
super();
index = i;
}

Twisty (){
this(2);
}

look at this code. you can clearly see the call to super class constructor. Believe me, this is exactly similar to your code.
what happens here is, if you don't add the super() call, java adds it for you. if you add this() or super call, then java doesn't add the default super call. note that the default super call is always with no arguments. in this way. if your super class doesn't have a constructor with no arguments, this gives a compile error, because java always create super call with no args and the super class doesn't have it.
Hi,

I have a problem of the jetty embedded server with the servlets. First I start the jetty embedded server and sends a request to the server. In the server, a servlet is running and according to the request,the request is forward to a jsp by the servlet. The problem is, when I am doing this, it gaves an exception. It comes from the place where I forward the request from the servlet to the jsp.

Here is the doPost method in the servlet code.

protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException {

String requestXml = createRequestXml(request);

for (int i = 0; i < ecgsRequests.length; i++) {
String ecgsRequest = ecgsRequests[i];
if (requestXml.indexOf(ecgsRequest) != -1) {
String forwardUrl =
"/WEB-INF/jsp/response/" +
forwardMappings.get(ecgsRequest);//this is where the exception comes.
try {
request.setAttribute("xml", requestXml);
request.getRequestDispatcher(forwardUrl)
.forward(request, response);
} catch (ServletException e) {
response.sendError(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
}
============================================================================

And here is the place where I have the server code.

server = new Server();
SocketListener listener = new SocketListener();
listener.setPort(8080);
server.addListener(listener);

WebApplicationContext webappcontext = new WebApplicationContext();
webappcontext.setContextPath("/");
webappcontext.setWAR("/home/madura/simulator.war");
WebApplicationHandler webApplicationHandler = new WebApplicationHandler();
webappcontext.addHandler(webApplicationHandler);
webappcontext.addHandler(new ResourceHandler() );
server.addContext(webappcontext);
server.start();
=============================================================================

This is the client who calls the server.

client = new HttpClient();

method = new PostMethod("http://192.168.0.233:8080/myapp");
header = new Header("content-type", "text/xml");
method.setRequestHeader(header);
RequestEntity requestEntity = new StringRequestEntity(toSent, "text/xml", "ISO-8859-1");//toSent is the //String to be sent.
method.setRequestEntity(requestEntity);
int statusCode = client.executeMethod(method);
==============================================================================

Can any one help me?
thanks in advance.

Madura...
15 years ago
Hi

I have a servlet and when client make a post request, i can see that the post method is called twice. I am using the jetty embedded server here. If I used the tomcat, it works fine.

what can be the problem?
thanks in advance.

here is the servlet code for the post method.
Thanks for the help.



[BSouther: Added UBB CODE tags]

[ December 10, 2008: Message edited by: Ben Souther ]
[ December 16, 2008: Message edited by: Ulf Dittmer ]
15 years ago
Hi

I need to call a java method within the jstl tags. Is there a way to do it?
I saw in a forum that it is not possible. Is it true?
I also need to get the return value back.

thsnks in advance.
Madura.
15 years ago
JSP
collection is a data structure like arrays.
generics make collections type safe!

when you say 'ArrayList al',
the al is an ArrayList , and like that, ArrayList is a Collection.
in this code no generic applied.
so, you can insesrt anything(String,Integer,or any customer object) to this ArrayList.

but in the other form,
when you say, 'ArrayList<String> al',
you can only insert Strings to it.No Integers and anything else.
here,"<String>" is the generic type.
"ArrayList" is the collection.
15 years ago
Do you need to limit the number of objects to be created?
If that is your problem, I don't think you can do that.
but you can call the garbage collector when you need to remove unnecessary objects.but it also not guaranteed.
15 years ago
Hi
compiler takes "double" for the default type for decimal numbers.
why dont you ask "why compiler takes int as default rather than long"?
you know the answer.that's compiler's choice.
decimal numbers are supposed to be larger than integers. so compiler takes 'double' as default rather than float.
15 years ago
Hi...
Can we use adler32 to compare two strings?
I have a hashmap with a String as it's value field and the key is adler32 checksum of that string.I want to check whether this hashmap contains another string.I get the checksum of that and compare it with keys in hash map.is it correct?
15 years ago