wood burning stoves 2.0*
The moose likes Servlets and the fly likes web-inf vs meta-inf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "web-inf vs meta-inf" Watch "web-inf vs meta-inf" New topic
Author

web-inf vs meta-inf

selvakumar Thiyagarajan
Greenhorn

Joined: Oct 06, 2008
Posts: 28
I am new to j2ee....
What is the difference between web-inf and meta-inf?
what is the difference between cookies and session? [
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Welcome to the JavaRanch, Selvakumar. I'm not sure that this is the best place to ask a question like that. You tend to get answers faster and of better quality when you ask them in a forum that's specific to the topic you're interested in.

However, here you are:

It's not "web-inf" and "meta-inf". Although you can often mis-capitalize filenames in Windows, you can't do that on a Unix system. And there are cases even in Windows where it won't work right. So you need to always properly capitalize. I don't like case-sensitive stuff myself, but that's the way they designed it.

Anyway, WEB-INF is the folder just under the root of a WAR that holds information that you don't want to be accessible to a client via a URL request. Specifically, it holds the web.xml, classes, and lib directories, but you can put anything you want to hide from the client there.

META-INF is what discriminates a JAR file from a plain ZIP file. It holds the manifest file and may hold other deployment information as needed.

Since a WAR is a JAR, a WAR will have a META-INF, but obviously a non-web JAR doesn't have any use for WEB-INF.

I'll leave the cookie/session question for someone else.


Customer surveys are for companies who didn't pay proper attention to begin with.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

I'll take a whack at sessions and cookies.

HTTP is a stateless protocol. What this means is that every time the user makes a request, such as by typing in a URL in the browser's address bar or by clicking a link or button, it is treated by the server as a new request completely unrelated to any prior requests. For static content this is acceptable. For something like an online store this is not acceptable because you often need to make multiple requests to select items and pay for them.

A session is a logical entity meant to identify the start and end of a series of interactions with the application. The application will track the user's usage from the start of the session to the end of the session. How and when to start a session is up to the application. For example, and online store migth start a session when you log in and end the session when you log out or after you complete and order.

There are two common mechanisms used to simulate state, and thus track a session, within the stateless HTTP protocol. One is to provide a session id number and embed that into, for example, a hidden field of the web page. Then when the user clicks a link or button this session id is returned to the application which uses this information to locate the session data for the user. Another mechanism is to provide a "cookie" which is stored by the browser. The browser then returns the cookie to the application on each request.

In addition, a cookie can be stored on the user's PC. That is how application such as the Java Ranch forum can keep you logged in even if you shut down your PC. The cookie stores your account information and Java Ranch uses that to identify you.

I don't see a general web application forum, so I am guessing that this topic might be better for the servlets forum (it was a toss-up between that and jsp), so I am moving it.
[ November 21, 2008: Message edited by: Peter Johnson ]

JBoss In Action
Pankaj Kumar Dubey
Greenhorn

Joined: Mar 19, 2010
Posts: 1
Perfect explanations.
Thanks a ton guys.
I had never found such detailed explanation on this topic.

Pankaj.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web-inf vs meta-inf