Re: Allow Servlet to Control "100-continue" response

2011-06-19 Thread Pid
On 18/06/2011 06:53, Rehtron wrote:
> Hi
> 
> Currently if a client supplies the "Expect: 100-continue" header on a POST
> or PUT, Tomcat appears to send the response header ("100-continue") before
> passing control to the servlet.

Out of interest, are you asking to control specifically the 100
response, or all access to the servlet?

Are you currently implementing access control logic inside the servlet?


p

> I need to use the servlet  to control this response and accept/reject the
> request before receiving the request content, Is there anyone could give me
> some advice?
> 
> Thanks.
> 




signature.asc
Description: OpenPGP digital signature


A Tomcat 6 Socket Server

2011-06-19 Thread netfolio

To whom is reading this mail.

Hello,

For some time i have been learning some server technologies for my own  
needs. I have tried PHP but the way its constructed or the way it  
handles scripts for object oriented programing wasn't suitable for me.  
Java is more the way i think of programing and that is why i thought  
to give a try on Tomcat.


I have looked for books. Most or all of them covers only JSP, JSF or  
JDBC but non of them covers TCP - socket communication in details such  
as the ServerSocketFactory, the JSSEFactory or the ThreadPool. I could  
mention some more issues when setting up a socket based application  
like SocketPermision.


I wrote this mail in hope for answers, guidance or best practice for  
writing a Socket based application server for handling ByteArray  
communication.


Where can i get the knowlage? How can i get smarter?

Thank you in advence,
Herendi Kristóf Pál
Budapest, Hungary - 2011 June the 11th.

ps:

To give you some idea of what i was try to accomplish, here is a  
pseudo code for a Java Socket Server:


// ServerMain.java
package Server;

import java.net.ServerSocket;
import java.net.Socket;

public class ServerMain {
private NewConnections newConn;
private LogedInUsers ConnMemb;
private UserList userList;
private CommunicationGroups ComGroups;


public ServerMain(){
userList = new UserList();
ConnMemb = new LogedInUsers();
newConn = new NewConnections();
ComGroups = new CommunicationGroups();
try{

ServerSocket serevrSock = new ServerSocket();
Socket clientSocket;
while(true){
System.out.println("Server ready, waiting for a client...");
clientSocket = serevrSock.accept();
new ConnectionHandler(clientSocket, userList, newConn,  
ConnMemb, ComGroups).start(); // extends Thread

}
}catch(Exception e){
System.out.println("Server startUp error: "+e);
}
}
public static void main(String args[]){
new ServerMain();
}
}

// ### END

Its simple.
I have spent some time to try to translate it for Tomcat but with out  
any refference i couldnt find the way to make it work.


If you would like to see the Tomcat version i would be happy to post  
it, but before i would like to see an experts "best practice", if i  
can have :)



-
  Externet Webmail: http://webmail.externet.hu



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



Re: Allow Servlet to Control "100-continue" response

2011-06-19 Thread Simon Olofsson

On 2011-06-18 13:46, Mark Thomas wrote:

>  You can use a Filter as mack Lu suggested

Wrong.


Thanks for the correction.
In StandardWrapperValve the request is acknowledged before the 
FilterChain is constructed. I should've looked it up :)


Simon


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



Re: Allow Servlet to Control "100-continue" response

2011-06-19 Thread Rehtron
Thanks to all who reply.

Yes, I am developing a REST interface for a large file storage system by
Servlet & Tomcat.

The Expect 100-continue is highly inefficient for LARGE file transfer, I
need to validate HTTP header by our access control logic when PUT a file, if
the headers is invalid, the transfer request  will be refused before the
client to send the body.

But I cannot implement this scenario by Servlet, Tomcat will always pass the
request header & body to my Servlet at once.

I will investigate the Tomcat Valve mechanism, but one thing is for sure,
the Valve based implementation depend on the Tomcat private implementation,
that means I cannot use Jetty to do unit test.

Can Servlet 3.0 Comet implement this?

Thanks.

Zijian.

2011/6/19 Pid 

> On 18/06/2011 06:53, Rehtron wrote:
> > Hi
> >
> > Currently if a client supplies the "Expect: 100-continue" header on a
> POST
> > or PUT, Tomcat appears to send the response header ("100-continue")
> before
> > passing control to the servlet.
>
> Out of interest, are you asking to control specifically the 100
> response, or all access to the servlet?
>
> Are you currently implementing access control logic inside the servlet?
>
>
> p
>
> > I need to use the servlet  to control this response and accept/reject the
> > request before receiving the request content, Is there anyone could give
> me
> > some advice?
> >
> > Thanks.
> >
>
>
>


Re: A Tomcat 6 Socket Server

2011-06-19 Thread Rehtron
Hi

Tomcat is a Servlet container, Servlet abstract HTTP interaction,  HTTP is
application layer protocol, it encapsulate the socket and bytes processing.

For socket processing, I think your should refer to some frameworks of
transfer layer protocol like Netty, XSocket and Mina.

Zijian

2011/6/19 

> To whom is reading this mail.
>
> Hello,
>
> For some time i have been learning some server technologies for my own
> needs. I have tried PHP but the way its constructed or the way it handles
> scripts for object oriented programing wasn't suitable for me. Java is more
> the way i think of programing and that is why i thought to give a try on
> Tomcat.
>
> I have looked for books. Most or all of them covers only JSP, JSF or JDBC
> but non of them covers TCP - socket communication in details such as the
> ServerSocketFactory, the JSSEFactory or the ThreadPool. I could mention some
> more issues when setting up a socket based application like SocketPermision.
>
> I wrote this mail in hope for answers, guidance or best practice for
> writing a Socket based application server for handling ByteArray
> communication.
>
> Where can i get the knowlage? How can i get smarter?
>
> Thank you in advence,
> Herendi Kristóf Pál
> Budapest, Hungary - 2011 June the 11th.
>
> ps:
>
> To give you some idea of what i was try to accomplish, here is a pseudo
> code for a Java Socket Server:
>
> // ServerMain.java
> package Server;
>
> import java.net.ServerSocket;
> import java.net.Socket;
>
> public class ServerMain {
>private NewConnections newConn;
>private LogedInUsers ConnMemb;
>private UserList userList;
>private CommunicationGroups ComGroups;
>
>
>public ServerMain(){
>userList = new UserList();
>ConnMemb = new LogedInUsers();
>newConn = new NewConnections();
>ComGroups = new CommunicationGroups();
>try{
>
>ServerSocket serevrSock = new ServerSocket();
>Socket clientSocket;
>while(true){
>System.out.println("Server ready, waiting for a client...");
>clientSocket = serevrSock.accept();
>new ConnectionHandler(**clientSocket, userList, newConn,
> ConnMemb, ComGroups).start(); // extends Thread
>}
>}catch(Exception e){
>System.out.println("Server startUp error: "+e);
>}
>}
>public static void main(String args[]){
>new ServerMain();
>}
> }
>
> // ### END
>
> Its simple.
> I have spent some time to try to translate it for Tomcat but with out any
> refference i couldnt find the way to make it work.
>
> If you would like to see the Tomcat version i would be happy to post it,
> but before i would like to see an experts "best practice", if i can have :)
>
>
> --**---
>  Externet Webmail: http://webmail.externet.hu
>
>
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@tomcat.**apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


FW: How to configure Tomcate 7 to remove OutOfMemory permgen error

2011-06-19 Thread Thomas Adler


Hi!

I am trying to use MyEclipse - I have simple database with 5 tables and I am 
trying to use MyEclipse Spring 3 CURD application scaffolding to generate 
Spring CRUD application, that uses Spring 3, Hibernat, Java Servlets 3, JSF 2 
and Primefaces 2.1 JSF components - as I understand - Tomcat 7 support such 
applications. My problem is that during deployment of generated application 
Tomcat 7 reports OutOfMemory permgen error. I have experienced similar error on 
other application servers previously (e.g. Glassfish), but I could remove it 
then by changing server configuration.

I have tried to change Tomcat 7 configuration as well - e.g. added JAVA_OPTS to 
Catalina configuration file, added environment variable JAVA_OPTS to my 
Microsoft Vista machine:
"-XX:PermSize=1024M -XX:MaxPermSize=1024M"
but permgen error occurs again and again (even after restarting computer and so 
on). I am using Tomcat 7.0.14.
So - the question is - how to configure Tomcat 7 to increase the available 
memory?

If I have tried to deploy my application on Tomcat 6 and for biggest part it 
gone well, namely, at the end it does not work, because Tomcat 6 is not for 
Servlet 3 (as I understand), but at least - there were not permgen errors.

Thanks for an help!
Thomas

  

Re: Allow Servlet to Control "100-continue" response

2011-06-19 Thread Pid
On 19/06/2011 11:59, Rehtron wrote:
> I will investigate the Tomcat Valve mechanism, but one thing is for sure,
> the Valve based implementation depend on the Tomcat private implementation,
> that means I cannot use Jetty to do unit test.

Why not test with Tomcat instead?


> Can Servlet 3.0 Comet implement this?

Servlet 3.0 OR Comet.  They are not the same, in any case Async requests
are unrelated to your original inquiry.


p



signature.asc
Description: OpenPGP digital signature


Re: FW: How to configure Tomcate 7 to remove OutOfMemory permgen error

2011-06-19 Thread Pid
On 19/06/2011 20:57, Thomas Adler wrote:
> 
> 
> Hi!
> 
> I am trying to use MyEclipse - I have simple database with 5 tables and I am 
> trying to use MyEclipse Spring 3 CURD application scaffolding to generate 
> Spring CRUD application, that uses Spring 3, Hibernat, Java Servlets 3, JSF 2 
> and Primefaces 2.1 JSF components - as I understand - Tomcat 7 support such 
> applications. My problem is that during deployment of generated application 
> Tomcat 7 reports OutOfMemory permgen error. I have experienced similar error 
> on other application servers previously (e.g. Glassfish), but I could remove 
> it then by changing server configuration.
> 
> I have tried to change Tomcat 7 configuration as well - e.g. added JAVA_OPTS 
> to Catalina configuration file, added environment variable JAVA_OPTS to my 
> Microsoft Vista machine:
> "-XX:PermSize=1024M -XX:MaxPermSize=1024M"
> but permgen error occurs again and again (even after restarting computer and 
> so on). I am using Tomcat 7.0.14.
> So - the question is - how to configure Tomcat 7 to increase the available 
> memory?
> 
> If I have tried to deploy my application on Tomcat 6 and for biggest part it 
> gone well, namely, at the end it does not work, because Tomcat 6 is not for 
> Servlet 3 (as I understand), but at least - there were not permgen errors.

If you're using Tomcat inside Eclipse, you have to find the IDEs
configuration mechanism - editing the Tomcat config won't help as it
uses separate files.

This is an IDE question, rather than a Tomcat one, it comes up
sufficiently frequently that you'll probably find similar questions and
relevant answers in the MyEclipse/Eclipse forums.


p



signature.asc
Description: OpenPGP digital signature


Re: Feature request: "fullstart" command

2011-06-19 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Mladen,

On 6/17/2011 1:21 AM, Mladen Turk wrote:
> On 06/17/2011 12:14 AM, Christopher Schultz wrote:
>>
>> On 6/16/2011 5:03 PM, Francis GALIEGUE wrote:
>>>
>>> I was actually wondering about these. I think I have my answer now :/
>>> Solutions in C or other languages are many to achieve that, Java has
>>> none.
>>
>> Correct: native code has to be written. tc-native notwithstanding, the
>> Tomcat team doesn't like to work with native code too much, and I can
>> understand why: it's a total minefield. Different OS versions, different
>> architectures, different c-library discrepancies, etc.
> 
> There ARE tomcat developers that are quite fun of C code and
> regularly participate in various "native" projects, so this
> has nothing to do with that.

I wasn't trying to suggest that there was any fear of native code...
just that it's really only used when necessary (APR, for instance).

>> Even if someone wrote something like this in native code, the result
>> would be essentially a fork() call which would clone your JVM, which
>> isn't going to be a fast process at that late stage of the game (in JVM
>> time, that is).
> 
> Exactly, and the fork() doesn't work with JVM. fork() only forks the
> single thread, so all your monitor, GC, memory threads are not there.
> For JVM, fork() is only valid if followed by execv which is basically
> what Runtime.exec does.

Yes, but the "daemon" function calls fork() and then the /parent/ exist,
which would ruin everything. I don't believe there's another way to drop
in to the background after a process is launched like that.

> Also there is a question of portability. Windows doesn't have fork().

Yup. There are ways of making it work, but it's just another way for
native code to bite you in the butt.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3+rZMACgkQ9CaO5/Lv0PDPBgCdG2Q2reBf9ipIy6KYFQ0fqwrm
e8MAnjcgLSM9IxmePdf5OQPT+LU4MUVW
=6KNG
-END PGP SIGNATURE-

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



Re: A Tomcat 6 Socket Server

2011-06-19 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Herendi,

On 6/19/2011 4:06 AM, netfo...@uw.hu wrote:
> I have looked for books. Most or all of them covers only JSP, JSF or
> JDBC but non of them covers TCP - socket communication in details such
> as the ServerSocketFactory, the JSSEFactory or the ThreadPool. I could
> mention some more issues when setting up a socket based application like
> SocketPermision.

You don't want a book on servlet programming, you want one on Java
Socket programming. I haven't read it, but there's one called "TCP/IP
Sockets in Java, Second Edition". Amazon reviews are all (3) 5-star.
It's from 2008 but not a lot has changed in terms of the socket API in
Java AFAIK.

Some of the old Core Java books and stuff like covered socket
programming, even if only briefly.

> I have spent some time to try to translate it for Tomcat but with out
> any refference i couldnt find the way to make it work.

Tomcat already implements TCP/IP services to handle the HTTP(S)
protocol(s), so there's no real need to re-invent it in order to run
within Tomcat. If you are implementing your own sockets for non-HTTP
conversations, there's no reason to have Tomcat in the mix at all...
just run your program standalone.

You probably couldn't make your program work because you didn't make it
into a context listener, filter or servlet, the only three types of
objects Tomcat will instantiate and initialize for you on webapp deployment.

I think you are making a mistake by involving Tomcat in your project, at
least given the information you have provided thus far.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3+tJcACgkQ9CaO5/Lv0PChnACfbTC9+qSB6L5Bz8eaOIzh6o3c
jxsAoJ3uDl6aa17DT3o8tA70D7i0omeK
=hiM1
-END PGP SIGNATURE-

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