I am n开发者_StackOverflowew to java servlets. I studied some code about servlet but I really want to know more basic things and how it works. I just wonder what type of material/content can be sent from java servlet to a browser. Like http request or something? And how does brower know how to deal with this material? In addtion, for java bean. I know it is a java class. But, what is the purpose behind the development of the java bean concept.
You need to do some background reading, start with something such as this tutorial
We can answer specific questions when you get stuck, but conceptual material is not best addressed by a Q&A site such as this.
We usually use servlets that understand the HTTP protocol, so a browser sends an HTTP request, the servlet sends a response. Often the response is in the form of HTML which browsers know how to render into a nice human-readable page.
Java Beans: don't worry about them yet, just think of them as yet another Java Class.
What type of material/content can be sent from java servlet to a browser?
A servlet can return any kind of data to the browser (or whatever else made the request). The data is wrapped in a ServletResponse
object, usually a HttpServletResponse
.
The response contains both the actual data and also meta data in the form of response headers, although we are now moving into the realm of HTTP, rather than servlets. You know how HTTP works, right? Yo
How does brower know how to deal with this material?
The response headers typically hint to the browser what type of data the response is, whether it is text, html, XML, etc. This is given by the response header called Content-Type. Again this is standard HTTP stuff, not really specific to servlets.
What is the purpose behind the development of the java bean concept?
The java bean standard is a convention used for writing POJOs. There are many tools that are specifically designed to work with classes written to the java bean standard. In relation to servlets and HTTP, the best example is probably JSTL, which allows you to access objects in a JSP so long as they follow the bean standard.
I really want to know more basic things and how it works. I just wonder what type of material/content can be sent from java servlet to a brower. Like http request or something? And how does brower know how to deal with this material?
Servlet sends HTTPResponse to the browser , and from the content-type header browser determines what type of data it is. is it a pdf, audio file ..
for java bean. I know it is a java class. But, what is the purpose behind the development of the java bean concep
See What is the point of JavaBean
精彩评论