aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes 2) getContext - absolute path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "2) getContext - absolute path" Watch "2) getContext - absolute path" New topic
Author

2) getContext - absolute path

Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Again another new thread to discuss this method....so that we don't cross post with the other methods in the same thread....
Acc to the API in the Spec:
SRV.14.2.8.1

getContext(String)
public ServletContext getContext(java.lang.String uripath)
Returns a ServletContext object that corresponds
to a specified URL on the server.
This method allows servlets to gain access to the
context for various parts of the server, and as
needed obtain RequestDispatcher objects from the
con-text.
The given path must be begin with “/”, is
interpreted relative to the server’s document
root and is matched against the context roots of
other web applications hosted on this container.

Probably worth another example with forward maybe....
Well, forward to another ServletContext on the same server.
- satya


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Here goes..........
Forwarding a request to a servlet in my Root web-app to the examples web-app......


- satya
faiza haris
Ranch Hand

Joined: Oct 17, 2000
Posts: 173
Hi
Thanx for starting diff posts for the methods...
Some things are still confusing.....
1)From the srv 8.4
forward may be called by calling servlet ONLY when no output has been committed to client.

Do we commit output by out.println()?
If i am using forward, what is the use of using out.println(); It gives no output and also no error if used. just forwards to the called servlet no matter where u put the out.println statement.
2)How can i check the output data in the response buffer.
By using response.isCommitted() and finding if it is true or false.But where shall i put the out.println code?? to verity the
specs
If the output exists in the response buffer that has not been committed the content must be
cleared before the target servlet's service method is called.If response is committed an IllegalStateException must be
thrown.

This paths thingi has led me to ..... wonderland
Having fun! yeah sure!
thanx
faiza
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Do we commit output by out.println()?
When the response (or part of it) is flushed to the client, then we say that the output is committed. Refer to the "autoflush" attribute.
This can happen in more than one ways. One, the flush() method is called on the out obj. Secondly, when the buffer is full (and the autoflush is true, which is the default) the server flushes the drain...errr...output to the client.
If i am using forward, what is the use of using out.println(); It gives no output and also no error if used. just forwards to the called servlet no matter where u put the out.println statement.
That is the intended behavior. Read your other post. This uses the flush() on the out obj and look for the IllegalStateException in your catalina logs.
Axel and I had a discussion on this.

2)How can i check the output data in the response buffer.
By using response.isCommitted() and finding if it is true or false.

I haven't tried this though.
But where shall i put the out.println code?? to verity the specs
Again the link abv used the out.println() and the out.flush() methods to verify the IllegalStateException, if flushed before the forward() method. Also, out.println() method calls after the forward will be ignored. You shouldn't see them on the client.
regds.
- satya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2) getContext - absolute path
 
Similar Threads
forwarding to a different webApp
Please clraify this...
Sharing session data between web apps
Accessing different WAR resources
A Question in Requesting Context ?