Re: tomcat session id

2012-07-15 Thread Konstantin Kolinko
2012/7/15 Elias Kopsiaftis :
> thank you, and it wasnt working thats why i asked. there must be something
> else wrong in my code

Session is recognized by sessionid sent either via a "Cookie" header
in HTTP request, or as a path parameter in URL of HTTP request.


You can inspect what is actually sent to Tomcat by your "client"
either by using network traffic inspection with a tool like Wireshark,
 or via configuration of an AccessLogValve in Tomcat.  Some references
should be in the FAQ.


If neither info are sent by your "client" program, the session cannot
not be associated with your request and a new session will be created
if a session is needed. (When that happens, a "Set-Cookie" header will
be included in the HTTP response).

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Embedded Tomcat 6 & 7 logging to file

2012-07-15 Thread Konstantin Kolinko
2012/7/16 Benjamin Muschko :
> Hi,
>
> I'd like to redirect the embedded Tomcat's startup logging messages to a
> file. What I am looking for is something like this:
>
> ...
> Initializing ProtocolHandler ["http-bio-8080"]
> Initializing ProtocolHandler ["http-bio-8091"]
> Starting service Tomcat
> Starting Servlet Engine: Apache Tomcat/7.0.11
> ...
>
> So far I haven't found a way of making this work. My first approach was to
> add a FileHandler to the context's logger:
>
> Handler fh = new FileHandler("output.log", true);
> fh.formatter = new SimpleFormatter();
> fh.level = Level.ALL;
> fh.encoding = "UTF-8";
> context.getLogger().logger.addHandler(fh);
>
> It works fine for the context in Tomcat 7 but doesn't give me the result I
> am looking for.

context.getLogger() returns logger for certain named log category
only. As a coincidence, it is the same one as used by log methods in
Servlet API. Other Tomcat components use other log categories (aka
logger names).


> Also trying to capture System.out and System.err and
> writing it to a file doesn't solve my problem:
>
> System.setOut(new PrintStream(new File("output-file.txt")));
> System.setErr(new PrintStream(new File("output-file.txt")));
>

If java.util.logging starts before you run the above code, it can
create a ConsoleHandler using original stderr and stdout.

Your setOut() and setErr() will have no influence on it.


> I guess I am not clear on how the embedded Tomcat implementation logs the
> messages to the console and how I can change it.

java.util.logging.ConsoleHandler for the default log category writes
messages to the console. If none were configured, nothing were printed
there.


See java.util.logging documentation in JDK. Essentially its bootstrap
is controlled via certain system properties when your java application
(the one that embeds Tomcat) starts.

> Could somebody clarify this
> for me. It would be great to see and example that would work for embedded
> Tomcat 6 & 7.
>

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Solved - Connecting Tmcat and IIS

2012-07-15 Thread Vijaya

Andre Warnier, thanks very much pointing the shortfall in my message.

I myself have been using isapi_redirector for more than 3 years without any 
problem and suddenly for unexplainable reasons (I am sure it was not the 
isapi_redirector problem but some other problem in our server that was 
driving me crazy) from my server end, I could not make the isapi_redirector 
work in our server and this new software helped me solve the problem.


In my opinion both the connectors are fairly straight forward to install and 
only wish more support will be available in both of these tools.


Regards,
Vijaya

-Original Message- 
From: André Warnier

Sent: Saturday, July 14, 2012 4:59 PM
To: Tomcat Users List
Subject: Re: Solved - Connecting Tmcat and IIS

Vijaya wrote:

Hello Everyone,


I want to post this message so that if you are struggling with
isapi_redirector to connect Tomcat and IIS. From one of the posts in
forums.iis.net, I came to know about a new redirector for IIS7
http://tomcatiis.riaforge.org. after wasting around a month to make the
isapi redirector failed in my server.  This new redirector installation 
has
an automatic installation that will make necessary changes automatically. 
No

need to change the registry, properties file and add virtual directories.
This one worked very well for me.



Vijaya,

it is always nice to hear about alternative open-source methods to fill 
particular
requirements, and from their homepage at least, this new connector looks 
really nice.
So thank you for the information, and hopefully this will result in more 
people trying it

out and reporting about it.

This being said, a note : in your message above, you seem to imply that 
isapi_redirector
(the Windows version of mod_jk), which is a project under the Tomcat 
umbrella and which is
supported on this list, is difficult to install and configure etc. and that 
this other

software is much better and easier.
Not to take anything away from the "Boncode AJP connector" (as it is named 
on the
webpage), but for a balanced interpretation of the above I would advise any 
readers to
first scan the list archives, for the thread entitled "iis not looking for 
jsp in tomcat

webapps folder" for the full story.

The isapi_redirector/mod_jk connector has been around for many years, has 
been installed
and configured and is being used succesfully by many thousands of people on 
production
websites worldwide, in a very wide range of configurations and 
circumstances.
It is also well-supported and kept very closely in sync with changes in 
Tomcat.
And, the configuration and usage of mod_jk and isapi_redirector being 
practically the
same, it is in effect multi-platform, running under Windows as well as under 
Linux and

multiple Unix variations.
In contrast, the Boncode AJP connector is one year old, and is 
single-platform(Windows).
This is not at all to say that this new connector is not an excellent piece 
of software (I
don't know, I have not tried it yet), but the fact that for Vijaya it was 
much easier to

deal with is not necessarily a general circumstance, yet.



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org 



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: tomcat session id

2012-07-15 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Elias,

On 7/15/12 3:52 PM, Elias Kopsiaftis wrote:
> thank you, and it wasnt working thats why i asked. there must be
> something else wrong in my code

Would you care to *post* your code? Perhaps someone with Comet
experience could give you an opinion...

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlADWMQACgkQ9CaO5/Lv0PBZUwCePZ010rYels8flsPIVmABVKb+
nF8An3CquLuIK/RqxYknymrLmf8vRMiS
=xaqS
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: Calling Bootstrap.main from a Java program

2012-07-15 Thread Caldarale, Charles R
> From: Mike O'Leary [mailto:tmole...@uw.edu] 
> Subject: Calling Bootstrap.main from a Java program

> When I tried this running my Java program in Eclipse, the call 
> to Bootstrap.main(new String[]{"start"}) did not return.

The thread that calls Bootstrap.main() ends up waiting for input on the 
shutdown port - which a thread dump would easily show you.

> running startup.bat in a command prompt window gets Tomcat 
> running and then returns to a command prompt.

You appear to have missed that startup.bat kicks off catalina.bat in a separate 
process.

> Is there a way to call Bootstrap.main(new String[]{"start"}) 
> in an application's main thread so that it returns and Tomcat
> continues running?

You shouldn't really be doing it that way, but disabling the shutdown port in 
your server.xml might work.  

> What is the best way to start and stop Tomcat programmatically from
> a Java application? If it is better to do it using a different class,
> such as Tomcat or Embedded, could someone point me to information 
> about how to do that?

Use the Tomcat class; Embedded is deprecated.  Read the Javadoc for 
org.apache.catalina.startup.Tomcat.  You could also try launching Tomcat in a 
separate process, rather than inside the JVM you're already using.

> I tried using the Tomcat class recently and I couldn't get it to 
> work either.

Can't provide help without specifics.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Embedded Tomcat 6 & 7 logging to file

2012-07-15 Thread Benjamin Muschko
Hi,

I'd like to redirect the embedded Tomcat's startup logging messages to a
file. What I am looking for is something like this:

...
Initializing ProtocolHandler ["http-bio-8080"]
Initializing ProtocolHandler ["http-bio-8091"]
Starting service Tomcat
Starting Servlet Engine: Apache Tomcat/7.0.11
...

So far I haven't found a way of making this work. My first approach was to
add a FileHandler to the context's logger:

Handler fh = new FileHandler("output.log", true);
fh.formatter = new SimpleFormatter();
fh.level = Level.ALL;
fh.encoding = "UTF-8";
context.getLogger().logger.addHandler(fh);

It works fine for the context in Tomcat 7 but doesn't give me the result I
am looking for.  Also trying to capture System.out and System.err and
writing it to a file doesn't solve my problem:

System.setOut(new PrintStream(new File("output-file.txt")));
System.setErr(new PrintStream(new File("output-file.txt")));

I guess I am not clear on how the embedded Tomcat implementation logs the
messages to the console and how I can change it. Could somebody clarify this
for me. It would be great to see and example that would work for embedded
Tomcat 6 & 7.

Thanks,

Ben

--
View this message in context: 
http://tomcat.10.n6.nabble.com/Embedded-Tomcat-6-7-logging-to-file-tp4984104.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Calling Bootstrap.main from a Java program

2012-07-15 Thread Mike O'Leary
I would like to be able to start and stop Tomcat from a Java program running on 
a Windows machine. I looked at the contents of startup.bat, shutdown.bat and 
catalina.bat, and it looks like one easy way to do that would be to set system 
properties that correspond to the -D command line arguments as they are set up 
in the script files, and then call Bootstrap.main with a list argument that 
contains either "start" or "stop". When I tried this running my Java program in 
Eclipse, the call to Bootstrap.main(new String[]{"start"}) did not return. I 
don't understand why this is, because running startup.bat in a command prompt 
window gets Tomcat running and then returns to a command prompt. Is there a way 
to call Bootstrap.main(new String[]{"start"}) in an application's main thread 
so that it returns and Tomcat continues running?

I also tried calling Bootstrap.main(new String[]{"start"}) in a separate 
thread, but I must not have done it right, because when I call 
Bootstrap.main(new String[]{"stop"}) it claims to stop Tomcat but there is 
still a process listening on the port that I designated.

What is the best way to start and stop Tomcat programmatically from a Java 
application? If it is better to do it using a different class, such as Tomcat 
or Embedded, could someone point me to information about how to do that? I 
tried using the Tomcat class recently and I couldn't get it to work either.

I am working with Tomcat 7.0.25 x64 on Windows 2008 Server.
Thanks,
Mike


Re: tomcat session id

2012-07-15 Thread Elias Kopsiaftis
thank you, and it wasnt working thats why i asked. there must be something
else wrong in my code

On Sun, Jul 15, 2012 at 3:50 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Elias,
>
> On 7/15/12 1:37 PM, Elias Kopsiaftis wrote:
> > ok i appreciate the input, but for now i will stick with the comet
> > approach because i read that websocket for tomcat 7 is still
> > experimental and i already built a lot of logic around the comet
> > approach. does anyone know the answer to my original question?
>
> As long as one servlet was called long-enough before the second one
> that the session could be created and its id returned to the client
> *and* sessions are supported, then yes, both servlets should have
> access to the same session data.
>
> It should have been easy to test this on your own ...
>
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAlADHvsACgkQ9CaO5/Lv0PCwaACfej2clhjZIZ+UpF2CpNCoOtIX
> HvUAniuzrjEf7AakeL6ONaIN736TImlr
> =1ZqX
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: tomcat session id

2012-07-15 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Elias,

On 7/15/12 1:37 PM, Elias Kopsiaftis wrote:
> ok i appreciate the input, but for now i will stick with the comet
> approach because i read that websocket for tomcat 7 is still
> experimental and i already built a lot of logic around the comet
> approach. does anyone know the answer to my original question?

As long as one servlet was called long-enough before the second one
that the session could be created and its id returned to the client
*and* sessions are supported, then yes, both servlets should have
access to the same session data.

It should have been easy to test this on your own ...

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlADHvsACgkQ9CaO5/Lv0PCwaACfej2clhjZIZ+UpF2CpNCoOtIX
HvUAniuzrjEf7AakeL6ONaIN736TImlr
=1ZqX
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: tomcat session id

2012-07-15 Thread Elias Kopsiaftis
ok i appreciate the input, but for now i will stick with the comet approach
because i read that websocket for tomcat 7 is still experimental and i
already built a lot of logic around the comet approach. does anyone know
the answer to my original question?

On Sat, Jul 14, 2012 at 1:07 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> André,
>
> On Jul 14, 2012, at 6:03, André Warnier  wrote:
>
> > Elias Kopsiaftis wrote:
> >> Well basically, For the output servlet, I am using comet to keep the
> >> connection alive and push things out to the client when they are
> available.
> >> This program is a chat program with a drawing capability, so two people
> can
> >> draw on the same canvas and chat with each other.
> >
> > Isn't this just the kind of thing that "websocket(s)" is supposed to be
> made for ?
>
> Comet is basically a precursor to Websocket: the ideas are vaguely the
> same and the use cases are nearly identical.
>
> Elias, if I were you, I would focus on Websocket moving forward... Comet
> is going to see less and less action (globally, not just in Tomcat) a time
> goes on.
>
> -chris
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>