Amit Das

Ranch Hand
+ Follow
since Mar 05, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amit Das

thanks David for ease up as well

ServletConfig's reference.getClass() will gimme the Class object for ServletConfig....right....
But i need to see the source code, i.e. say Tomcat's servlet containers implemetation for it....hope u got my point...

Thanks,
Amit
15 years ago
Hi all,

I know that when the Server receives a request for the first time, it calls init(ServletConfig), where the Servlet Container passes the object of ServletConfig to the servlet in consideration.
My question is where can i find the implementation for the object of ServletConfig which is provided by the Servlet Container?

Regards,
Amit

[Editted topic and some content to tone it down - Dave]
[ July 19, 2006: Message edited by: David O'Meara ]
Hi all,

I know that when the Server receives a request for the first time, it calls init(ServletConfig), where the Servlet Container passes the object of ServletConfig to the servlet in consideration.
My question is where can i find the implementation for the object of ServletConfig which is provided by the Servlet Container???

Plz let me know ASAP..........

Regards,
Amit

[cleaned up the topic - Dave]

[ July 19, 2006: Message edited by: David O'Meara ]
[ July 19, 2006: Message edited by: Bear Bibeault ]
15 years ago
Hi DongShang,

Well i understood what you are trying to convey here, and i knew this when i was writing my previous post.......
may be i'm unable to convey what i want to.

Let me try once more.....

I think there is a diff in these terms:
1. Doc root of a web app
2. Doc root of the server
3. Servlet Container root
4. Servers doc base

Mind you, that its Servlet Container Root and NOT
Servlet Container DOC root
.
IMHO, doc base is a place in context (in literal terms..) of a web app, like test is a web app in your case.
So in the webapps folder if we have a folder called test, the doc base for that app would be directly under test directory excluding WEB-INF, as
WEB-INF shud not be served to the clients.
So when i say doc base for the server, i think, i shud be
%Tomcat-Home%/webapps/ROOT/ and not %Tomcat-Home%/webapps/, as webapps itself is not an application.
Hope i'm able to convey this time.
Correct me if i was wrong anywhere.

Regards,
Amit
[ June 07, 2006: Message edited by: Amit Das ]
I hv a confusion here, infact i disagree to the previous post here, let me explain why...........

Every web-app has a doc root, similarly in Tomcat under webapps directory we have ROOT, which happens to be the default app for this server.

if i say:
http://localhost:8080/
only, than i get a default app for the server which the ROOT, i think the server doc root is under ROOT (Correct me if I'm wrong....)

So as per my understanding, Servlet Container root shud be under ROOT directory. I may be wrong in this, kindly correct me, if there is any misconception here.

Regards,
Amit
hi all,

I'm referring to the meaning of Servlet Container root

Say if i've Tomcat, does it mean:
1. Tomcat/ or
2. Tomcat/webapps/ROOT ???

Kindly clarify.........

Thanks,
Amit
Hi all,

This is an excerpt from the java doc of Servlets:

When an application stores an object in or removes an object from a session, the session checks whether the object implements HttpSessionBindingListener. If it does, the servlet notifies the object that it has been bound to or unbound from the session. Notifications are sent after the binding methods complete. For session that are invalidated or expire, notifications are sent after the session has been invalidatd or expired.



The above is basically an excerpt from the description of javax.serlet.http.HttpSession.

My doubt is in the portion in bold above, meaning i dont understand which notifications are they talking about? Is it the notifiaction which will be sent to the HttpSessionAttributeListener, which is registered in the web.xml; because, if the attributes implement the HttpSessionBindingListener, as soon as the session invalidates, first they would be notified by the container. Is it that immediately after that notification will be sent to the HttpSessionAttributeListeners???

Plz clarify....

Thanks,
Amit
[ June 05, 2006: Message edited by: Amit Das ]
Ok can u tell me if you put some file in Tomcat bin folder, can we access
it like this--------------->

File f = new File("<file-name>"); ???

P.S: file-name can be sth like test.jar

Regards,
Amit
Hi Niranjan,

Thanks for replying.....
Well I'm at one with you for whatever u've said, but can u tell me one more thing what do they mean by putting the '?' before and after the req.getAttribute(?javax.servlet.include.servlet_path?) ......

Regards,
Amit
If anyone is reading the Mannings book, can they check it out???

Regards,
Amit
Can anyone look into this and answer please.

Regards,
Amit
Hi all,

What is the difference b/w ServletContext.getRequestDispatcher(String path) and
ServletRequest.getRequestDispatcher(String path) ?

Where the API doc says:
For ServletRequest.getRequestDispatcher(String path)

"The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root. ...."



and for ServletContext.getRequestDispatcher(String path)

"The pathname must begin with a "/" and is interpreted as relative to the current context root.............."



Both look kinda similar to me....can anyone expalin the differnce with an EXAMPLE??

Regards,
Amit
Hi all,

I was reading the Mannings book for SCWCD, Sec 4.8.3 Acessing request-scoped attributes with RequestDispatcher


"One important aspect of the new servlet specification involves he ability of an included or forwarded servlet to access request information through attributes. The name of the attribute dependes on whether
RequestDispatcher.include() or RequestDispatcher.forward() was invoked."



After this a list of Attributes available to included/forwarded servlets for obtainng information about request is given; like Attribute for included servlet are
javax.servlet.include.request_uri, javax.servlet.include.context_path,
javax.servlet.include.servlet_path, javax.servlet.include.path_info and
javax.servlet.include.querry_string
.

Similarly the Attributes for forwarded servlet
are same with include being replaced by forward.

Further the author says.....

"The values corrrespond to the parameters of the original
request, without regard to further forwarding
. For example, if a forwarded servlet invokes req.getServletPath() the result will be the same as if the java.servlet.include.servlet_path attribute had been acquired with
req.getAttribute(?javax.servlet.include.servlet_path?)"



My question is shouldn't this be
"......the result will be the same as if the
java.servlet.forward.servlet_path attribute had been acquired with
req.getAttribute(?javax.servlet.forward.servlet_path?)" ???

Plz clear the doubt, if possible.

Regards,
Amit
Hi all,

As we know that there is a header name called Refresh.
NOw if i want the ouput html generated to get refreshed say after every
2 mins how do I do this?

I've tried this:


but it doesn't work.........

CAn anyone give the answer??

Regards,
Amit
[ May 30, 2006: Message edited by: Bear Bibeault ]
15 years ago
JSP
Hi all,

Please refer this code snippet:


I've written a code to get a JAR file whic is kept on the server side.
According to the Manning's Book for SCWCD,

if we store any resource (here it's the .jar file) in the bin directory of Tomcat and we write



it will create a file object, but when I'm writing the code as the author
says, I get a a Runtime Exception
"java.io.FileNotFoundException: test.jar (The system cannot find the
file specified)"


1.So Is the author wrong in saying this, that File object is created if we
just give the file name in the constructor of File and keep the file in
the bin folder of Tomcat?

2. Now as u can see in my code; I'm creating the File object by giving the
absolute path of file. If I try to access this servlet from the browser,
instead of getting the file to download, I get as decoded on the browser,
which is not as the author says it should. The author says...
"If we want to send a binary file, for example a JAR file, to the client.."

It means it will be sent as file only, but when i try the code, there is
a different behavior. CAn anyone explain??

But again if i use ServletContext.getResourseAsStream(String path) (plz
use the commented code by uncommenting it and comment the previously
uncommented code) I get the file as downloadable.

Run the code and answer, if possible.

Thanks,
Amit