Re: Method Post and Get with TiniHttpServer

"Manuel J. Goyenechea" <goya-FyHrgQ2OBzd8UrSeD/[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.tini
Organization Servertec
Message-ID <001a01c42e40$4225e1a0$1f02a8c0@stec>
Doc,

I think that the problem is that in the HelloServlet the text fields names
use lower case and that in the HelloServletDeux the field names are not in
lower case. For example the Nom field is named nom and not Nom as referenced
in HelloServletDeux. Try:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public class HelloServletDeux extends HttpServlet
{
    public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
    {

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        out.println("<HTML>\n<BODY>\n" + "<H1>Recapitulatif des
informations</H1>\n" + "<UL>\n" + "  <LI>Nom: " +
request.getParameter("nom") + "\n" + "  <LI>Prenom: " +
request.getParameter("prenom") + "\n" + "  <LI>Age: " +
request.getParameter("age") + "\n" + "</UL>\n" + "</BODY></HTML>");
    }
}

I am not familiar with TiniHttpServer, but the above should work with
Servertec Internet Server TINI Edition, www.servertec.com.

Good luck,

Manny

----- Original Message ----- 
From: "Doc Gloumy" <[email protected]>
To: <tini-6tN4nzCoH/[email protected]>
Sent: Thursday, April 29, 2004 4:35 PM
Subject: [TINI]Method Post and Get with TiniHttpServer


> I want to pass data to a servlet, and I dot understand how I can use the
> post and get method with TiniHttpServer, I use two servlet, one with the
> form, and the other wich display data,
>
> This is the first :
>
> import javax.servlet.*;
>
> import javax.servlet.http.*;
>
> import java.io.*;
>
> public class HelloServlet extends HttpServlet {
>
>     public void service( ServletRequest request,ServletResponse
> response) throws ServletException, IOException {
>
>         response.setContentType( "text/html" );
>
>         PrintWriter out = response.getWriter();
>
>             out.println( "<FORM Method=\"GET\"
> Action=\"http://10.10.10.81/servlet/HelloServletDeux\">" );
>
>             out.println( "Nom :<INPUT type=text size=20 name=nom><BR>" );
>
>             out.println( "Prénom :<INPUT type=text size=20
> name=prenom><BR>" );
>
>             out.println( "Age :<INPUT type=text size=2 name=age><BR>" );
>
>             out.println( "<INPUT type=submit value=Envoyer></FORM>" );
>
>     }
>
> }
>
>
> and the twice :
>
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.util.*;
>
> public class HelloServletDeux extends HttpServlet {
> public void doGet(HttpServletRequest request,
>                     HttpServletResponse response)
>       throws ServletException, IOException {
>
>     response.setContentType("text/html");
>     PrintWriter out = response.getWriter();
>
>     out.println("<HTML>\n<BODY>\n" +
>                 "<H1>Recapitulatif des informations</H1>\n" +
>                 "<UL>\n" +
>         "  <LI>Nom: "
>                 + request.getParameter("Nom") + "\n" +
>                 "  <LI>Prenom: "
>                 + request.getParameter("Prenom") + "\n" +
>                 "  <LI>Age: "
>                 + request.getParameter("Age") + "\n" +
>                 "</UL>\n" +
>         "</BODY></HTML>");
>   }
> }
>
>
> The compil is ok, and I arrive to display the html but the data are
> "null", is there an good method to pass data enter two servlet ?
>
> If not, can I put these two servlet in only one ? but i dont know how to
> use the send button as a condition in a if structure
>
> PS : Thanks to Kelly Smith and Shawn for their help with TiniHttpServer,
> it run good now ;)
>
> -- 
> /**************************************************
> GARCIA Patrick alias Doc Gloumy
> BTS Informatique et Reseaux pour l'Industrie et les Services
> Port : 06-89-51-54-01 Tel : 05-61-07-65-58
> Trésorier, electricien,
> Responsable logistique et materiel de PcRézoo
> www.pcrezoo.net
> [email protected]
> ICQ : 94469133
> MSN : [email protected]
> **************************************************/
>
>
>
>
> _______________________________________________
> TINI mailing list
> TINI-6tN4nzCoH/[email protected]
> To UNSUBSCRIBE, edit your profile, or see list archives:
> http://lists.dalsemi.com/mailman/listinfo/tini
>


_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.