Yes, is a kind of mock testing. But I have to instantiate a session, because
I don’t use a browser to access my instance of tomcat. My app just uses some
tomcat files to process jsp's and Servlets.
But, when my app is started, the manager is still null. (e.g. I get a NPE
when I call context.manager())
Maybe I have to instantiate the manager by hand, but I'll try that first.

Now I'm trying to add some parameters to the request, e.g. username and
password. And then I call the cookie, created by the app. (it should work
nicer ;-))

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:[EMAIL PROTECTED] Namens Bill Barker
Verzonden: woensdag 24 oktober 2007 3:41
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

Nope, this won't work.  The Request needs to be mapped before TC knows how 
to find the Session.

After the Context is started, it should have a Manager (if you haven't 
explicitly configured one).  I'm guessing that you are doing some sort of 
Mock unit testing, and you want the Session configured before you run your 
test.  In that case, you want something like (after you call start):
    Manager manager = context.getManager();
    Session session = manager.createSession("MySessionId");
    manager.add(session);
    HttpSession hsession = session.getSession();
    hsession.setAttribute(foo, bar);



"Auke Noppe" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Hi,

I have the app working. But I want to set some attributes on the session
(like a user). Does anyone knows how I can get to the HttpSession? I tried
to create a org.apache.catalina.connector.Request via
connector.createRequest() and invoke the request.getSession() method, but I
always receive null from the request. The manager of the context is empty I
found out. Should it not be instantiated/set during startup?

I there another way to get a reference of a HttpSession?

Regards,

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:[EMAIL PROTECTED] Namens Bill Barker
Verzonden: dinsdag 23 oktober 2007 3:27
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

It is possible, but not easy.  The Connector is integrated pretty tightly
with the Catalina code now.  In particular, you can't just call the invoke
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a
reference to it by calling getProtocolHandler() on the Connector, and then
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don’t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.8/1089 - Release Date: 23-10-2007
19:39
 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to