Yes, when you are sending the subsequent request to the servlet, it is
calling the doGet method.  In your case, doPost is only being called the
first time when user submits the form.  You can either use the HttpSession
object to hold the information.  Moreoever, another way I can think of is:
=> Put all the implementation/functionality in one private method which
takes a boolean value, request and response objects, as parameter.  Let's
say the private method is performStuff(boolean isFirstTime,
HttpServletRequest request, HttpServletResponse response)

=> Call this method from doPost and doGet methods with appropriate flags.
The code would look something like this:
----------------------------
public void doGet(.......) throws IOException, ServletException
{
    performStuff(false) // because the subsequent requests are calling the
doGet method.  therefore, this is not the first call!
}

public void doPost(.......) throws IOException, ServletException
{
    performStuff(true, request, response) // Form is submitted and this is
the first call to the servlet
}

private void performStuff(boolean isFirstTime, HttpServletRequest request,
HttpServletResponse response)
{
    ..... provide implementation here based on isFirstTime value
}
----------------------------

Hope this helps!

----- Original Message -----
From: Harkishin Nachnani <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 18, 2000 12:19 PM
Subject: Calling the same servlet again and again using REFRESH


> Hello
>
> I want to call different methods of a class based on whether the servlet
> is called for the first time and all other subsequent calls.
>
> I have a main FORM which calls the servlet for the first time and passes
> parameters "first_time=true" through the query string.
> <FORM Method="POST Action =
> "http://hnoffice/cservlets/cWebcallback?first_time=true"
>
> So depending on this query string, few methods are called in the
> servlet.
>
> Actually I want to constantly update the user with information after
> every 5 seconds.
> So I am calling this servlet again and again after every 5 seconds, but
> now I want to pass parameter "first_time=false"
> since the servlet is being called for the second time ( and not the
> first time)
>
> So I used the refresh concept  with parameter "first_time=false"
> <Meta http-equiv = "refresh"
> content="5,http://hnoffice/cservlets/cWebcallback?first_time=false">
>
> But in the servlet, when I try to retrieve the query string
> "first_time=false", it gives me the same query string of
> "first_time=true"...
>
> Is is right to pass the query string in the content URL ???
>
> All the methods are called in doPost( ) method of the servlet...But the
> data is posted only once through the main form...Is this creating a
> problem ???
>
>
> Any help would be really appreciated !!!
>
>
> Thanks in advance,
>
> Harkishin Nachnani,
> MicroAutomation, Inc., 5160 Parkstone Drive, #140, Chantilly, VA 20151
> Tel: (703) 378-7000 x609 Fax: (703) 378-4321
> Web: www.microaut.com
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to