Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

Java Autopostback?

Thread view: 
Vittorix - 25 Jan 2008 23:48 GMT
Hi everybody,

I'm writing a web server in Java for html and servlets.
when the server receives a GET request, it works fine.

problem: when I use POST, the server program stops and the submit button has
to be clicked another time or the page has to be manually refreshed (after
that it works fine).
so, the program waits for the client to send a new signal/request.
The problem is caused by a in.readLine() statement:

 if(method.equals("GET") && URI.contains("?"))
      paraLine = URI.substring(URI.indexOf("?")+1, URI.length());
 else if(method.equals("POST"))
      paraLine = in.readLine(); // in the POST request, the parameters are
in the http request body

how to avoid that?

Signature

ciao
Vittorix

derek - 26 Jan 2008 00:08 GMT
> Hi everybody,
> I'm writing a web server in Java for html and servlets.
[quoted text clipped - 11 lines]
> in the http request body
> how to avoid that?

My suggestion would be to get some software to watch the data that is getting sent to your pogram.
I like Fidler from microsoft.
Then when you see what data is being sent you can get a better idea of what you need to do.

.
=====================================================
THIS IS MY SIGNATURE. There are many like it, but this one is mine.
Vittorix - 26 Jan 2008 01:01 GMT
> My suggestion would be to get some software to watch the data that is
> getting sent to your pogram. I like Fidler from microsoft.
> Then when you see what data is being sent you can get a better idea
> of what you need to do.

thanks, but didn't help.
Fiddler doesn't catch traffic on localhost.
I know I can workaround with the server name, but even checking what is sent
doesn't solve the problem.
it still waits. there must be a specific issue and solution.

Signature

ciao
Vittorix

Naveen Kumar - 26 Jan 2008 09:28 GMT
> > My suggestion would be to get some software to watch the data that is
> > getting sent to your pogram. I like Fidler from microsoft.
[quoted text clipped - 10 lines]
> ciao
> Vittorix

in.readLine() makes the program wait for line feed ('\n') or a
carriage return ('\r').. guess that might cause a problem.. y dont u
try using read() ??

Cheers
Naveen Kumar
Vittorix - 28 Jan 2008 19:12 GMT
> in.readLine() makes the program wait for line feed ('\n') or a
> carriage return ('\r').. guess that might cause a problem.. y dont u
> try using read() ??

yes, this is the idea. and I did thys way, thanks:

 else if(method.equals("POST"))
               { // POST  method
                       int ch;
                       int len = Integer.parseInt((String)
headers.get("Content-Length")); // POST request Content-Length header
                       paraLine = "";
                       for(int i=1; i<=len; i++)
                       {
                           ch = in.read();
                           paraLine += (char) ch; // in the POST request,
the parameters are in the http request body
                       }
               }

Signature

ciao
Vittorix



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.