Socket POST connection close
Hello all,
I was wondering if there was a way to close a connection once the server writes back to the connection? I have this post:
var conn = new Socket;
//conn.timeout = 300;
//conn.timeout = 10;
conn.timeout = 2;
var tempzzz = $.hiresTimer;
conn.open(vHost);
conn.write("POST " +vSubDir+"/update.asp HTTP/1.1\r\n");
conn.write("Host: " + vHost + "\r\n");
conn.write("Content-Length: " + data_string.length + "\r\n");
conn.write("Content-Type: application/x-www-form-urlencoded\r\n");
conn.write("\r\n");
conn.write(data_string);
var reply = "";
reply = conn.read(999999);
conn.close();
var myTime = $.hiresTimer/1000000;
alert("found reply "+myTime)
When I run this code with the timeout set to 2 my alert states found the reply in 1.75 sec.
When I run this code with the timeout set to 10 my alert states found the reply in 9.87 sec.
When I run this code with the timeout set to 300 my alert states found the reply in 126.23 sec.
Any idea how to close the connection and therefore make indesign active again the moment a server replies? I cannot use a get because I am sending a lot of data to the server which would exceed the URL size limit. Any information would be helpful, thanks!
Hi,
when you are talking about the weblogic level, connection pooling is implemented through configiration level,
Please note we have 3 variables in configiration level :
1. InitialCapacity
2. MaxCapacity
3. CapacityIncrement
initialCapacity means the number of physical connections which will open during the starting of the Server.
which can be initially 0, MaxCapacity means the number of maximum connection which can be opened. i mean maximum physical connections.CapacityIncrement means if it finds like the number of opened coonection is used then it will again open that much Capacity increment of connection. Please not this will not increase the MaxCapacity.
when you are closing the cnnection using connection close methord, you are returning the connection to connection pool , which will increase the number of connection available in the connection pool.
Regards,
Anu Unnithan
Similar Messages
-
Socket Channel Connection - Continuous read
Hi all,
I am new to socket programming. This is where I am stuck...I need to read from a channel 'continuously', i.e messages are continuous published and I need to keep on reading it. Below is my code for review....I am just getting the 1st line of the message. please suggest..Thanks in advance
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.util.Iterator;
import java.util.Set;
public class TestConnection {
private static Charset charset = Charset.forName("ISO-8859-1");
private static CharsetDecoder decoder = charset.newDecoder();
public static void main(String[] args) throws IOException {
SocketChannel sc = null;
String desthost = "172.19.67.33";
int port = 5002;
InetSocketAddress isa = new InetSocketAddress(InetAddress.getByName(desthost), port);
try {
sc = SocketChannel.open();
sc.connect(isa);
System.out.println(" Message--> " + readFromChannel(sc, 4096));
} catch (Exception e) {
e.printStackTrace();
} finally {
if (sc != null)
sc.close();
public static String readFromChannel(SocketChannel sChannel, final int size) throws IOException {
int numBytes = 0;
boolean hasRead = false;
ByteBuffer inBuffer = ByteBuffer.allocateDirect(size);
CharBuffer charBuffer = CharBuffer.allocate(size + 100);
StringBuffer dataRead = new StringBuffer();
Selector selector = Selector.open();
System.out.println(" Is Connected--> " + sChannel.isConnected());
System.out.println(" sChannel.isBlocking()--> " + sChannel.isBlocking());
sChannel.configureBlocking(false);
System.out.println(" sChannel.isBlocking()--> " + sChannel.isBlocking());
sChannel.register(selector, SelectionKey.OP_READ);
try {
while (selector.select(20000) > 0) {
Set readyKeys = selector.selectedKeys();
Iterator readyItor = readyKeys.iterator();
while (readyItor.hasNext()) {
SelectionKey key = (SelectionKey) readyItor.next();
readyItor.remove();
ReadableByteChannel keyChannel = (SocketChannel) key.channel();
if (key.isReadable()) {
for (int i = 0;; i++) {
int count = 0;
if ((count = keyChannel.read(inBuffer)) < 0) // EOF
keyChannel.close();
throw new IOException("Socket lost connection during read operation");
numBytes += count;
if (!inBuffer.hasRemaining()) {
hasRead = true;
System.out.println("has read");
System.out.println("SUCCESSFUL, length of data read:" + numBytes);
inBuffer.flip();
decoder.decode(inBuffer, charBuffer, false);
charBuffer.flip();
selector.close();
return dataRead.append(charBuffer).toString();
if (i >= 2) {
break;
if (false == hasRead) {
System.err.println("has _NOT_ read");
System.err.println("length of data read: " + numBytes);
System.err.println("length of data read: " + numBytes);
if (numBytes > 0) {
inBuffer.flip();
decoder.decode(inBuffer, charBuffer, false);
charBuffer.flip();
System.err.println("ERROR, data read: " + dataRead.append(charBuffer).toString());
throw new IOException("Socket read operation timed out");
} else {
throw new IOException("Invalid Read Socket state");
} finally {
selector.close();
}The output is -->
Is Connected--> true
sChannel.isBlocking()--> true
sChannel.isBlocking()--> false
has read
SUCCESSFUL, length of data read:4096
Message--> 000c100000300000007f100700302E12008071104060400 Lane Communication Is OK 004d100500300302E0100000027000000000000000000000000000010845800000000000000000000000c100000302E01007f100700303E12008071104140200 Lane Communication Is OK 004d100500300303E0402350427000000000000000000000000000119107300000008500000000000000c100000303E00007f100700304E12008070704085600 Lane Communication Is OK 004d100500300304E0201521427000000000000000000000000000081090700000003640000000000000c100000304E00007f100700305X12008071104111600 Lane Communication Is OK 004d100500300305X0801411215000000000000000000000000000048892600000000810000000001000c100000305X00007f100700306X12008071104102600 Lane Communication Is OK 004d100500300306X0800660815000000000000000000000000000046838800000000760000000000000c100000306X00007f100700307X12008063003542200 Lane Communication Is OK 004d100500300307X1000445315000000000000000000000000000125509000000017220000000127000c100000307X000104100300300307X200807111727309311015004453030200000000000000000000000000000527000001020102000000001154210344501304E2008071116072500EZPASS TAG# 022 - 04522780 STATUS = VALID TYPE = INTERIOR FPT Program Status = Success 00012550910000001723000000012820104100300300305X200807111727325610815014112010200000000000000000000000000000000010201020102000000005146360015500121E2008071117010800MANUAL CASH IN EXIT MANUAL 00004889270000000082000000000100104100300300307X200807111727353911015004453030200000000000000000000000000000072000001020102000000001154220344700103E2008071117070600EZPASS TAG# 008 - 03623801 STATUS = VALID TYPE = INTERIOR FPT Program Status = Success 00012550920000001724000000012800104100300300307X200807111727379411015004453030200000000000000000000000000000072000001020102000000001154230344900401E2008071117181300EZPASS TAG# 006 - 00468916 STATUS = VALID TYPE = INTERIOR FPT Program Status = Success 00012550930000001725000000012800104100300300306X200807111727399610815006608010200000000000000000000000000000000010201020102000000000075910013300613E2008071117032500MANUAL
The out actually gives multiple line...but what should be the approach to read line by line continuously and keep parsing them......
kind regards -
I am getting this error when email comes in
I have tried setting up a new mail database on a different drive but it hasnt helped at all.
<[email protected]>, relay=none, delay=0, status=deferred (delivery temporarily suspended: connect to /maildat/socket/lmtp[/maildat/socket/lmtp]: Connection refused)
I have checked the .conf files that referenced the previous mail database to make sure they changed, and they had indeed changed to point to the new files. but so far... nothing.absolutely...
postconf
command_directory = /usr/sbin
config_directory = /etc/postfix
content_filter = smtp-amavis:[127.0.0.1]:10024
daemon_directory = /usr/libexec/postfix
debugpeerlevel = 2
enableserveroptions = yes
html_directory = no
inet_interfaces = all
luser_relay = bounceuser
mail_owner = postfix
mailboxsizelimit = 0
mailbox_transport = cyrus
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
messagesizelimit = 12582912
mydestination = $myhostname,localhost.$mydomain,memphisdns.com
mydomain = memphisdns.com
mydomain_fallback = localhost
myhostname = memphisdns.com
mynetworks = 192.168.0.0/24,216.37.68.34,216.37.68.45,127.0.0.1
mynetworks_style = host
newaliases_path = /usr/bin/newaliases
queue_directory = /private/var/spool/postfix
readme_directory = /usr/share/doc/postfix
sample_directory = /usr/share/doc/postfix/examples
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
smtpdpw_server_securityoptions = plain,login
smtpdrecipientrestrictions = permitsasl_authenticated,permit_mynetworks,reject_unauthdestination,permit
smtpdsasl_authenable = yes
smtpdtls_certfile = /etc/certificates/Default.crt
smtpdtls_keyfile = /etc/certificates/Default.key
smtpduse_pwserver = yes
unknownlocal_recipient_rejectcode = 550
virtualmailboxdomains = hash:/etc/postfix/virtual_domains
virtual_transport = lmtp:unix:/var/imap/socket/lmtp
imapd.conf
admins: cyrusimap
configdirectory: /Volumes/netdat/post/database
partition-default: /Volumes/netdat/post/store
unixhierarchysep: yes
altnamespace: yes
servername: memphisdns.com
quotawarn: 80
sievedir: /usr/sieve
sendmail: /usr/sbin/sendmail
lmtpdowncasercpt: 1
popauthgssapi: yes
tlscertfile: /etc/certificates/Default.crt
logrollingdays: 30
imapauthlogin: yes
logrolling_daysenabled: false
popauthapop: yes
enablequotawarnings: yes
lmtpover_quota_permfailure: yes
tlskeyfile: /etc/certificates/Default.key
imapauthplain: yes -
Converting socket mode connection to servelet mode.
Hi ,
e-bussiness version 11.5.10.2
database version 10gR2
how can we convert forms socket mode connection to the servelet mode connections ,
any help will be great apreciatable .Hi farhan;
Please check Hussein Sawwan's greatest post about similasr issue
Socket vs Servlet mode
You can also check [this search|http://forums.oracle.com/forums/search.jspa?threadID=&q=socket+mode+servelet+mode+&objID=c3&dateRange=all&userID=&numResults=15]
Hope it helps
Regard
Helios -
/var/imap/socket/lmtp: Connection refused
Hi,
I have problem with lmtp daemon. How can I a execute it manually?
I've executed:
serveradmin stop mail; serveradmin start mail;
killlall lmtpd lmtp; postqueue -f
But ... nothing works ...
Mails arrived but don't delivered to the mailbox because of the following error:
6FB133AA6609 1181 Tue May 5 20:45:05 email_account
(delivery temporarily suspended: connect to hansolo.galenics.net[/var/imap/socket/lmtp]: Connection refused)
I've try sudo -u _cyrus /usr/bin/cyrus/bin/lmtpd but nothing ...
Any Suggestion?
Thanks for all.Hi
Apart from the fact it could be any one of at least a dozen things the usual thing would be to do a search of the Mail Forum fist. This has been discussed before. Also its a good idea to post the umodified output of postconf -n.
A quick search for this year alone reveals:
http://discussions.apple.com/thread.jspa?messageID=8801406�
http://discussions.apple.com/thread.jspa?messageID=9065994�
http://discussions.apple.com/thread.jspa?messageID=9302503�
http://discussions.apple.com/thread.jspa?messageID=8802455�
That's not all. Search parameters I used:
http://discussions.apple.com/search.jspa?threadID=&q=%2Fvar%2Fimap%2Fsocket%2Flm tp%3AConnectionrefused&objID=f1236&dateRange=thisyear&userID=&numResults=15&rankBy=10001
Start from here and if these don't help keep posting and hopefully some of the more abler contributors might be able to help?
Tony -
Difference between connection = null and connection.close()
is it correct
connection = null means connection object is eligible for garbage collection and does not return to connection pool
and f or
connection.close() means the connection object return to the
connection pool
is there any other difference between this ....?????"connection = null;" is just like any other similar Java statement, it removes that reference to the object. If that was the last reference to the object, then it becomes eligible for finalization and garbage collection, with no guarantee that either will actually occur. However, normal connection pool implementation will have a seperate reference to the connection and if the connection has not been returned, will most likely consider the connection to be "leaked" - allocated but never returned, and unusable.
connection.close(); is a normal JDBC connection method; it (usually) closes the associated objects and releases the connection; it's not uncommon to explicitly close statements and resultsets instead of depending on connection.close(). A connection pooling implementation that works by extending the Connection class MIGHT change the meaning of close() and instead of actually closing, return it to the pool instead. Personally, I would consider such an implementation to be evil and a blight on good programming practices; changing the action of such standard methods is bound to cause trouble, IMHO. More normally, if you were using connection pooling, you would NOT close the connection, but rather call some special method to return the connection to the pool. -
Reg.Automatic posting period close and open
Dear Experts
We have to do Posting period close and open in MMPV every month, is there any way to do automatically as background job. Pls help me.
Thanks in advance
Rajakumar.KHi,
To open the MM period every month, you can schedule the batch job in background.
Use transaction code SM36 and the program name for this transaction code is RMMMPERI.
Use dynamic selection for the date, where u can give the date as a first day of next month and schedule the job for the last day of every month.
It is working fine in my system
I hope it will help. -
Web app Connection.close()...how to prevent
Hello
I am somewhat new to this, but I am developing an web application that will be a help desk of sorts for clients to log on and create trouble tickets, plus many other features. I have completed the project and it works fine when I first start tomcat but an unexpected state keeps occurring and I can't seem to figure it out.
After a while (I say a while cause I'm not sure exactly how long, but I'd say +5 hours) my application no longer will work and in the tomcat log I get the following message.
Could not execute a query statement!Connection.close() has already been called. Invalid operation in this state.
java.sql.SQLException: Connection:close() has already been called.
at com.mysql.jdbc.Connection.getMutex(Connection.java:1906)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1115)
at brokers.RelationalBroker.query(RelationalBroker.java:171)
the RelationalBroker.java is
package brokers;
* Created on May 12, 2004
* Class: RelationalBroker
* Package: brokers
* On-Track, Ticket Tracking System
* @author
* @version
* This Class is used as the super class for all of the child brokers
* for the database. The main purpose if this class is to allow all the
* child classes to share the open connection to the database and execute
* queries and updates on the database. This class is part of the brokers
* package.
//imports
import java.sql.*;
public class RelationalBroker {
//Instance Attributes
* The attribute con represented by a Connection object is used to hold
* the active connection to the database. This connection is shared with
* all of the child brokers.
private Connection con = null;
* The attribute statement represented by a Statement object is used to
* execute the query and update statements on the database by the child
* brokers.
private Statement statement = null;
* The attribute results represented by a ResultSet is used to hold
* the results of a query executed on the database.
private ResultSet results = null;
//Constructors
* Default constructor used to create a RelationalBroker object.
public RelationalBroker(){
// Getters
* The Getter getCon is used to get the Connection object.
* @return Connection con.
public Connection getCon() {
return con;
* The Getter getResults is used to get the ResultSet results.
* @return ResultSet results.
public ResultSet getResults() {
return results;
* The Getter getStatement is used to get the Statement object.
* @return Statement statement.
public Statement getStatement() {
return statement;
//Methods
* The method connect is used to connect to the database given a username
* password, location of driver, and URL of the database. This method also
* creates the Statement object to be used for queries ans updates on the database.
* @param driver A String containing the location of the database driver.
* @param URL A String containing the location of the database on a netowrk.
* @param user A String containing the username of the database account.
* @param pass A String containing the password of the database account.
public void connect(String driver, String URL, String user, String pass){
try{
Class.forName(driver);
con = DriverManager.getConnection(URL, user, pass);
statement = con.createStatement();
catch (ClassNotFoundException cExp){
System.out.println("Cannot find class for driver");
catch (SQLException sqle){
System.out.println("Error opening table or creating statement!: " + sqle.getMessage());
sqle.printStackTrace();
System.exit(0);
* The method closeConnection is used to close the active connection
* to the database.
* @return A boolean containing the status of the connection, True if closed
* false if open.
public boolean closeConnection(){
boolean isClosed = false;
try{
con.close();
isClosed = con.isClosed();
catch(SQLException sqle){
System.out.println("Error closing connection!" + sqle.getMessage());
//finally{
return isClosed;
* The method rollBack is used to execute a rollback statement on
* the database, to undo any changes since the last commit.
* @return void
public void rollBack(){
try{
con.rollback();
catch(SQLException sqle){
System.out.println("Could not execute a Rollback statement!" + sqle.getMessage());
sqle.printStackTrace();
* The method commit is used to execute a commit statement on the
* database, to make any changes final.
* @return void
public void commit(){
try{
statement.executeUpdate("commit");
catch (SQLException sqle){
System.out.println("Could not execute a commit statement!" + sqle.getMessage());
sqle.printStackTrace();
* The method query is used to exceute a query statement on the
* database to get back some results.
* @param query A String containing the query to be executed on the database
* @return a ResultSet containing the results.
public ResultSet query(String query){
results = null;
try{
//System.out.println("query: "+query);
results = statement.executeQuery(query);
catch(SQLException sqle){
System.out.println("Could not execute a query statement!" + sqle.getMessage());
sqle.printStackTrace();
//finally{
return results;
* The method update is used to persist or remove information
* from the database.
* @param update String containing the update string to be exceuted;
public void update(String update){
try{
statement.executeUpdate(update);
catch(SQLException sqle){
System.out.println("Could not execute an update statement!" + sqle.getMessage());
sqle.printStackTrace();
}//end classmy web.xml file to initialize with the database is as follows
<servlet>
<servlet-name>Connection</servlet-name>
<servlet-class>servlets.ConnectionServlet</servlet-class>
<init-param>
<param-name>url</param-name>
<param-value>jdbc:mysql://localhost/TICKETTRACK</param-value>
</init-param>
<init-param>
<param-name>driver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</init-param>
<init-param>
<param-name>user</param-name>
<param-value>---</param-value>
</init-param>
<init-param>
<param-name>password</param-name>
<param-value>---</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
the ConnectionServlet.java is
package servlets;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import problemDomain.*;
import brokers.*;
* Title:
* Description: This servlet is used to create a connection with .
* @author
* @version 1.0
public class ConnectionServlet extends HttpServlet{
private UserBroker uBroker;
private TicketBroker tBroker;
private CompanyBroker cBroker;
public void init() throws ServletException{
ServletConfig config = getServletConfig();
String user = config.getInitParameter("user");
String pass = config.getInitParameter("password");
String url = config.getInitParameter("url");
String driver = config.getInitParameter("driver");
uBroker = UserBroker.getUserBroker();
tBroker = TicketBroker.getTicketBroker();
cBroker = CompanyBroker.getCompanyBroker();
uBroker.connect(driver,url,user,pass);
tBroker.connect(driver,url,user,pass);
cBroker.connect(driver,url,user,pass);
/* This method is used to close the connection.
* @param none
* @return none.
public void destroy() {
try{
}catch(Exception ec){
System.err.println(ec);
}I hope this is enough information for someone to help out. I'm out of ideas and my searches on the web didn't turn up much.
I was thinking it was something to do with ConnectionPooling but I have never done that, or maybe its something to do with how I set up Connections or maybe its my Tomcat config or something to do with Mysql. I'm not even calling a Connection.close(), maybe that is my problem.
Any help would be greatly appreciated, I'm not just looking for an answer I really would like to know why this occurs and how it can be prevented.
Thanks,I really appreciate your reply and I can understand what you mean in theory(I think) but to actually implement it I'm having a little trouble.
So for this database pool, in my ConnectionServlet which gets initialized on startup, should I create a Collection of connections for each instance(make them local), and than create another method to retrieve one of these connection when needed and when finished release it back to the collection(close)? Or is there some built in mechanism that can easily do this?
I'm also reading up on that keep-alive you mentioned...it applies to the HTTP Connector element right? Is there a way to tell if this is an issue? I'm using Tomcat 5 and mySQL 3. I was talking with another guy here about using a connector to apache so it will work with the static pages and Tomcat do the servlet stuff, but I'm still trying to grasp all that.
I don't know if this matters but many instances/windows of the web app can be opened at one time with seemingly no problems.
Hope this made sense, like I said I'm pretty new to this so all I'm used to is simple configurations of web apps but hopefully I can advance further.
Thanks again, -
Read from socket failed: Connection reset by peer
On Solaris 10 SPARC I have NO problem with establishing SSH connections.
Here is proof:
# svcs -a | grep ssh
online Jun_02 svc:/network/ssh:default...but here is what can be found in /var/adm/messages
Jun 7 04:09:16 my_host sshd[11701]: [ID 800047 auth.crit] fatal: Read from socket failed: Connection reset by peerTHIS IS IMPORTANT!!!
This messages does not appear during I establish my ssh connection. It appears irregular.
Does anyone know whats going on ?Hi Darren,
that would make sense but I just made a test:
I have opened tail -f /var/adm/messages and from other host:
- telnet to it on port 22 - no message
- closed client during establishing connection - still no message
But I belive you must be right as I see no other possibility...
Can I turn on more detailed logger in message to be able to see IP address of all host who are trying SSH connection ?
Edited by: czezz on Jun 25, 2009 10:50 PM -
HI,
Is there any way to limit HTTP posting connections? I know I can limit SAP max conn. in transaction SMQS, but is there any way limiting plain HTTP post?
Now XI is posting XML messages with speed that receiver cannot handle...Hi,
If you do not send any payload in the http request you are going to get a http error.
For your second requirement, There is no any problem, You can use any existent tool, or maybe develop you own program.
Http client.
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417600)ID1536482550DB10501227175138097442End?blog=/pub/wlg/15296
Regards
Ivan -
Hi to all,
This is siddiqali working on sahrepoint 2010.I open my Web application then i got error as
HTTP/1.1 200 OK
Server: Microsoft-IIS/7.5
Connection: close
Can any one help me hoe to solve it
Thanks, Quality Communication Provides Quality Work. Mohammad Siddiqali.Hi Matthew ,
Thanks for responding .I have reattached the data base but getting trouble shoot as
The Workstation service has not been started.
."Can you tell me why it is showing.
Thanks, Quality Communication Provides Quality Work. Mohammad Siddiqali. -
ACE 4710 send Connection:Close when should be Keep-Alive
After user request to front end http to 10.85.10.4 (default 80) after a port redirect and action list header rewrite
header rewrite request host header-value http://10[.]85[.]10[.]4 replace http://10.85.10.67:84/jde/E1Menu.maf%1
I see the request go out (wireshark) to the back-end javaserver but in the Connection it's close not keepalive:
GET /jde/E1Menu.maf HTTP/1.1
Connection: Close
Host:10.85.10.67:84
After the get from the ACE the jserver replies with the JDE login screen but the ACE ignores it?Try by enabling persistence rebalance in an http parameter-map.
Also your rewrite rule is wrong, you've been mistaken regarding the role of the Host field I guess. What you try to configure in your config is a URL rewrite but it's not supported by the ACE. -
Connection closes autometically
Hi,
I am making multiplayer game,
my problem is:
a player after connecting to mediaserver, if he does not play
for some time , he losses connection with the mediaserver.
why the player is disconnected, i am not getting any
notification when player is disconnected, how to trace this.
and also i don't want the player to be disconnected if he
does not play for sometime.
please help me in solving this.
regards
avanthikaHorea Raducan wrote:
>
Is it true that if you close a connection, all the results sets
associated with that connection will be also closed and you don't have
to close them ?Yes. This is mandated by the JDBC spec. For safety and performance,
however, it is best if you close the result set asap, then close the
statement asap, and most crucially, never forget to close the connection.
The reason why you want to close resultsets and statements asap,
is because they may involve DBMS resources like cursors etc, and these
can be freed for re-use when you close the object, but may remain
unuseable for a while if you rely on the connection close() to
clean up after you.
Joe -
If I redirect url will database connection close ?
Can someone tell me how this would work ?
If I connect to the database and if the username and password is correct I redirect the user to a website using :
response.sendRedirect(response.encodeRedirectUrl("http:....");
and then I close the connections...
rs.close();
stmt.close();
connection.close();
Then if the user is valid will my connection close ? If not how do I close the connection ??Right now I have it this way:
if (rs.next()) {
response.sendRedirect(response.encodeRedirectUrl("http.........."));
else
something else and close connections
} -
Can i use the same socket to connect to more than one servers
hi,
I'm new to java. I want to know whether a socket created using Socket() constructor can be used to connect to multiple servers, not necessarily at a particular point of time. ie, i want to connect to various servers using a single socket and register some info abt them, possible using a loop, one by one. I use connect() method to connect to particular server.
In other words is Socket class is mutable.
Edited by: itsraja on Feb 25, 2008 5:50 AMIn short, I don't think so.
Setting the server name for a socket is in the constructor.
Socket s = new Socket("localhost", 501);I don't believe that there are any functions, such as:
s.setHost("localhost");
s.setPort(501);However, JavaDocs suggests that when you use the no-args constructor, your class becomes an automatic SocketImpl class, but you can't reach any of its variables unless you derive from the class, itself. But that's probably a bigger headache than it's worth.
Now TECHNICALY, if you didn't want to create a new variable, you could use:
Socket s = new Socket("localhost", 501);
s.close();
s = new Socket("remotehost", 502);
s.close();However, this is still creating a new instance and thus a new object in memory.
I hope this answers your question.
Let us know exactly what you're trying to do for a more exact answer.
~Derek
Maybe you are looking for
-
Loading Infopackages one at a time (i.e. one by one)
Dear All BI Experts, We are implementing SCM5.1 with BI7.0 We load a cube in BI with daily forecast data from APO, but unfortunately we have spotted one of the dates is wrong, so the data in the cube has been summing up incorrectly. That has now been
-
hi to all, How can i publish a query in portal and how can i change a published query in portal how can i publish multiple queries in one sheet?
-
Servlet Displaying Quotation Marks as Non-Printable Characters
I have a servlet which is reading an HTML file and displaying it's contents. My problem is that, in the output, quotation marks in the source html (" and ') are being reproduced as non-printable characters (). Furthermore, the same servlet prints the
-
Possible to SCREEN P2 clips in the FIELD without FCP?
I'll be in the field shooting Panasonic P2 cards and downloading to a mac laptop. I'm not sure if the producer has fcp on the laptop but I want her to be able to screen the p2 footage after it's saved off the card. What's the best way to achieve this
-
Okay, I just made the switch, and now I am lost...
i just switched to the iMac...which I adore...but there are a couple of things that are confusing me...I was having an issue with safari freezing, but I read some fixes on here, and I think I fixed it...problem is, the only way I can figure out how t