Arpit Purohit

+ Follow
since Jan 09, 2007
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Arpit Purohit

Do Inserting Unicode Data into Database has anything to do with Struts Action class???
Any is the sample code to insert unicode data into mysql using JDBC:

This can be used any where for the desired functionality.
12 years ago
Try following Javascript code snippet (tested on IE6 and Firefox 3.0.8)
Hi all,
I have created a class to use singleton Socket to connect to an IP. I want that at a time, only a single thread should be able to use this connection (use its InputStream and OutputStream).
Following is the code:

Further I will be using above class as follows:

Now my doubts are:
1. Is above code fine for multi threaded scenario
2. As Socket object is Static(and singleton), will it always return reference to same InputStream and OutputStream (implies they are also singleton).
If Yes than how to make InputStream and OutputStream thread safe.(one way is to use synchronized block in second code snippet)
I had worked on development of such application.
Try Robot class in java.
12 years ago
I am new to JMS and Message Queue. I have installed Sun's Open Message Queue on my system.I have created ObjectStore and Destination(Queue) and using java program to insert and fetch messages.
Following are the details:
1. Created ObjectStore MyObjectStore with following properties:-
  • java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory
  • java.naming.provider.url=file:///c:/tmp

  • 2. Created ConnectionFactory MyConnectionFactory and Destination MyQueue

    3. Code to access above queue:

    My problem is that I am able to access Message Queue on local machine only. I don't know how i can configure my MQ to be accessed on network or/and how to look up for MQ which is on remote machine in network.
    Can anybody help me on this.
    This is usually done by using an HTTP server (like Apache ).
    Use Virtual Host configuration to map a web application name of your choice with your
    For reference visit Apache Virtual Host Documentation
    12 years ago
    RESTful Web Services is a buzz word these days. I found it very easy to develop these kind of WS and would prefer to use it than SOAP based WS.
    Can anybody tell what are the Limitations of REST based WS as compare to SOAP based WS.
    12 years ago
    Use following code for reference:

    Further you can access txt1,txt2 and txt3 as parameters in the servlet(whose URL you are providing in Form's action attribute) and implement any functionality (like DB operations) .
    12 years ago
    The approach to use given auto generated classes to add record should be as follows:

    Rahul Babbar wrote:Yes....i think the problem is coming because you are doing
    user.setMydepts(new HashSet());
    According to this code, if there was anything in the original set, it should be removed....and it should be replaced by this new Set...
    So, hibernate is doing what it should, remove the original records, and then add the new records...
    I have not tested it, but some code like below should work.

    I agree with Rahul.
    In general, we do not use user.setMydepts(new HashSet()) as this method is to be used by hibernate internally to populate the HashSet.
    You are calling this statement after the HashSet is already been populated by Hibernate.
    Changing the approach of representation will work for the scenario.It seems that you want to implement this functionality using javascript.
    A Multi-Tab view on a single page will work fine where clicking on the link will open a new Tab for that particular asset (use Ajax to fetch data from that particular page).
    While using this approach, you can easily keep track of Tabs (which in turn represents an asset) and focus the Tab related to an asset if it is already open and user make attempt to click the link again.
    Generating Multi-Tabs using javascript can be easily found on www (although, dynamic generation of tabs need to be worked on)

    Hope this will help.

    Arpit Purohit
    Cookie is an option but it can be disabled by client.
    And by the way.... That was a doubt rather than issue.

    Lets say we want to implement login functionality using AJAX on client side.
    After login, the user information like email or screen name is to be saved in session.
    So my question was that if it is possible to access those parameters stored in session whenever we make
    next AJAX request?
    JDBC Connection is Just an example. It can be any kind of Connection.

    Lets talk about my specific problem:

    I am trying to build a web based Telnet client. I create a TelnetCient ( object
    to establish connection to remote server.
    Further, I store this object in Session so that it can be used for next command user wants to execute (without logging in again).
    In this scenario, for every user there will be a TelnetCient object which connects to remote server with user specific credentials.

    I will disconnect this TelneClient explicitly when user logs out. But what to do if user close the browser without logging out.

    Arpit Purohit
    12 years ago

    I have Object added to a Session which makes connection to another server(like Database-Connection or Socket).
    I use to close it explicitly when user logs out. But How to do this when user close the browser?

    Do the Session Invalidating due to session timeout in turn destroys all the objects it holds?
    And if the answer is Yes then what about the connection established by object with another server?
    How that connection can to be closed explicitly in such condition?

    Arpit Purohit
    12 years ago