Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

getting info about request object.

getting info about request object.

getting info about request object.

I want all the infomation about request object not only headers and mayby body or contents.
the page below don't show anything. what's the problem?

Thanks in advance.

<%@ page import = "java.io.*" %>
<%@ page import = "javax.servlet.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<title>Insert title here</title>
ServletInputStream is = request.getInputStream();
 StringBuffer sb = new StringBuffer();
    byte[] b = new byte[1024];
    for (int n; (n = is.read(b)) != -1;) {
        sb.append(new String(b, 0, n));
Replies continue below

Recommended for you

RE: getting info about request object.

all I can see are parameters and their values.

RE: getting info about request object.


In your code you output the data received on the standard input. The data available on the standard input is the data received through POST. And yes, that is the form data, that is the body of the request. What do you want more ?


RE: getting info about request object.

I've thought
request.getInputStream() gives the request hearder and body.
for example port, host name etc and of course the parameters and values.
yes you can get the information about headers by using other APIS like request.getHeaders...

you mean request.getInputStream() gives only the parameters and their values only if the request method is "post". right?

RE: getting info about request object.

API says about getInputStream() is like this.
Retrieves the body of the request as binary data using a ServletInputStream.
then request is composed of headers and body.
and body is composed of parameters and their values.
and headers can be viewed with     getHeaders(java.lang.String name)
and body can be viewed with getInputStream().
tell me more about request objects structure.
Thanks in advance.

RE: getting info about request object.


Yes. That is how all CGI and similar environments, including servlet containers, work.

I am not the right person to tell you more about them. I am able to help on small bugs, but better I do not explain. ( As I wrote, previous explanation was HTTP/CGI, not Java. )

You can find the experts in forum695: Sun: Servlets and JavaServer Pages (JSP), I suggest to ask there.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close