Abhishek Dwaraki

Ranch Hand
+ Follow
since Feb 13, 2006
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 Abhishek Dwaraki

Hello people...
I am doing an RMI project and I have run into a small problem. Hope someone can help me out. I have 3 RMI servers which all need to communicate via some back end channel (to do some time syncing work). I decided to use sockets for this since I have to send small amounts of data. The problem is that when I create the server socket in the constructor of one of my actual servers, it blocks the thread on creation. And the second instance of the actual server is not created at all. I will highlight it in the code below.

Is there SOME WAY that I can create a new thread and hand off just the socket part of the code below to the new one so that it can create and block without affecting the main thread executing?

public FrontEnd(String serverIP, int serverPort, String serverName, int processId, int portNum)
throws RemoteException
{
int FEserverPort = serverPort;
String FEserverIp = serverIP;

this.processID = processId;
this.socketPort = portNum;

try
{
FEReg = LocateRegistry.createRegistry(FEserverPort);
FEReg.rebind(serverName, this);

System.out.println ("Starting Server Instance on port " + FEserverPort);
System.out.println ("Server bound to name " + serverName);

BEReg = LocateRegistry.getRegistry(serverIp, backEndServerPort);
BEServer = (MessageInterface)(BEReg.lookup("tweetRMI"));

}
catch(Exception e)
{
System.out.println ("The Registry is causing an error");
e.printStackTrace();
}

try
{
this.serverSocket = new ServerSocket(socketPort);
this.incomingConn = serverSocket.accept ();
===================> Server socket creation and blocks here!!!
}
catch (Exception e)
{
System.out.println ("The Socket is causing an error");
e.printStackTrace();
}

objEATS = new ElectionAndTimeSync(processID, socketPort, incomingConn);
}

public static void main(String[] args)
{
// TODO Auto-generated method stub
try
{
FrontEnd serverObject1 = new FrontEnd("localhost", 9002, "feRMI", 2, 10002); =============> This calls the constructor and the thread blocks when the socket is created.
FrontEnd serverObject2 = new FrontEnd("localhost", 9011, "fe1RMI", 3, 10003); =============> This is never called since the thread has blocked due to the above call.
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
}
8 years ago
Hey Angela,
U need to change the return value of the method so that the return value is a NODE value. The method signature should look something like this... and then add the . Add a return statement after you insert and after you check for null and assign root to temp also, i.e in the initial part of the code. For a cross check could you just post the method where you are calling the add method....? It would be helpful to check out the assignment there also.
12 years ago
Angela,
Just put in a statement after you are done with the insertion. Think that this should take care of the problem. Just dash off a post about it in any case. Cheers....
12 years ago
Hey Angela,
Just as a matter of clarification, since you will be using the root node of the BST to start your iterations, I think that you have missed out on returning the root node on insertion. Maybe that is the problem, because without returning the root node on insertion, there is no way to set the node at the time that you create the node and insert it into the tree. Just check out that part about returning the current object or something like that. I think that you have missed out on a return statement.
12 years ago
Hey people,
This is the scenario.. I need to send a custom value in the header of my request alongwith the normal request headers and then retrive it in the destination servlet. For eg, I want to send the user name in the header of the request, whether it is from a servlet or from a JSP, and then retrieve the value in the servlet that processes the information. If it is a servlet to servlet communication, can the response headers be used to set and retrieve the value....? Someone plzzzzz advice in this regard and it is a bit urgent. Thanks in advance for the help. You can mail me at abhishek.dwaraki@gmail.com if you come up with anything plz.
12 years ago
Hey Guys,
This is the scenario... I need to set a value in the HTTP headers which are sent from the browser, i.e the JSP and need to retrieve that value in a servlet using getHeader() or an equivalent. For eg, I need to send a value like the username in the header and then retrieve the same in the servlet. I'm currently using the URLConnection class' addRequestProperty(String key, String value) to set the value and then retrieve it in the servlet using request.getHeader(). But it is returning null all the time.. plzzzz do let me know about the issue. The code is below.

JSP code :

<%URL url = new URL http://localhost:9090/MMPortal/servlet/ShowRequestHeaders");
URLConnection conn = url.openConnection();
conn.setAllowUserInteraction(false);
conn.setDoOutput(true);
conn.setRequestProperty("UserID","Abhishek");
%>


Servlet Code :

request.getHeader("UserID"); inside the doGet() method.

Please do advice on this. Thanks in advance.
12 years ago
Thanks a lot for the help pascal... It was a great help... Thanks once again...
12 years ago
I'm not leaving the formatting to setDate() or rather don't want to take it till there. Want to just finish with the formatting in the Java code without going till the JDBC driver. All the same, I did check out the setDate() method only after you gave me the idea. The only parameters that it took was the index position and the date. The date object while being created took only one parameter to the constructor, that was the time or date, depending on the class being used. There is no place where to specify the format string. Or maybe I was not good enough to find it. Please advice in this regard Pascal ... Thanks a lot.
12 years ago
The date is being stored as a Date object itself in the DB... And also the thing is i checked the documentation for the setDate() and setTime() methods in the PreparedStatement interface. I just specifies the MM.dd.yyyy format or the hh:mm:ss format. There is no mention of the AM/PM marker in the formatting. Plz do advice further in this regard. Thanks in advance.
12 years ago
Hey guys,
I'm using the SimpleDateFormat class to format my date and time in my program. The issue is that with the formatting of the system date, the am/pm marker is being returned in upper case. I need to store this in the database which could lead to issues later... Hence I need to format it in such a way that I obtain it in lowercase and I can't use the normal method of toLower() or anything like that.. I did not find any pattern string in the class that could return the marker in lowercase... Can someone help me out with this plzzzzzzzz....? Thanks in advance...
12 years ago
Thanks for the help Merrill... But even after changing that parameter the messages are not being displayed.. I'm not able to figure out why this is happening... I also have the corresponding message entry in my ApplicationResources.properties file... Plz do advice on any other pitfalls that are there... I'm stuch with this and unable to go ahead 'cos I'm not able to display any messages in the JSP...
12 years ago
I need to display messages using the html:messages tag in my JSP. The problem here is that the messages are not getting displayed due to some problem. I have coded the ActionMessages Object.add() directly in the Action class itself and not put it inside any error condition like it is normally done in the ActionForm's validate method... Inspite of just trying to display a message right outside, as soon as the Action Class is mapped into, there is no message being displayed... Someone plz advice on this... Any help will be appreciated and thanks in advance... The config file is alright... Will just put in the code snippets of the jsp and the Action Class..

This is from the Action Class :

ActionMessages message2 = new ActionMessages();
message2.add("This is a test message", new ActionMessage("testmessages.try","This is to test the ActionMessages Class"));

This is from the jsp :

<li>
<html:messages id="message">
<bean:write name="message" />
</html:messages>
</li>
12 years ago
With reference to the above post, both the JSP's are giving the same problem of not displaying the error msg... It does not pertain or restrict to one set of JSP's and Action classes.. Thanks in advance...
12 years ago
Here's my validation.xml file.... Hope this can do something to help tou figure out the problem... Plz do advice...

<!DOCTYPE form-validation
PUBLIC "-//Apache Software Foundation//
DTD Commons Validator Rules
Configuration 1.2//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_2_0.dtd">

<form-validation>
<formset>

<form name="AddressForm">
<field property="name" depends="required">
<arg position="0" key="Name" resource="false" />
</field>
<field property="address" depends="required">
<arg position="0" key="AddressForm.address" bundle="/com.jpmchase.mm.struts.ApplicationResources" />
</field>
<field property="emailAddress" depends="required">
<arg position="0" key="AddressForm.emailAddress" bundle="/com.jpmchase.mm.struts.ApplicationResources" />
</field>
</form>

<form name="StrutsValidationForm">
<field property="username" depends="required">
<arg position="0" key="StrutsValidationForm.name" resource="true" />
</field>
<field property="password" depends="required,minlength">
<arg position="0" key="StrutsValidationForm.password" bundle="/ApplicationResources.properties" resource="true" />
<arg position="1" name="minlength" key="${var:minlength}" />
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
</field>
<field property="testRangeValue" depends="required,intRange">
<arg position="0" key="StrutsValidationForm.testRangeValue" bundle="/ApplicationResources.properties" resource="true" />
<arg position="1" name="intRange" key="${var:min}" bundle="/ApplicationResources.properties" resource="true" />
<arg position="2" name="intRange" key="${var:max}" bundle="/ApplicationResources.properties" resource="true" />
<var>
<var-name>min</var-name>
<var-value>18</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>65</var-value>
</var>
</field>
</form>

</formset>
</form-validation>
12 years ago
Try doing a servlet mapping for the Action Servlet instead of the Front Controller like this.

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

And as an afterthought, check your package hierarchy. It should be identical with the one specified in the action mapping tag. Just check these out... It was where I was making a mistake...
12 years ago