Thank you very much.
It really works now the way I wanted to.
Rinaldo Bonazzo wrote:
> Try
> if(NAME.compareTo("")==0){.....}else{....}
> Rinaldo Bonazzo
> email:[EMAIL PROTECTED]
>
> -----Messaggio originale-----
> Da: A mailing list for discussion about Sun Microsystem's JavaServlet
> API Technology. [mailto:[EMAIL PROTECTED]]Per conto di
> Theodor Goulas
> Inviato: marted� 21 novembre 2000 11.51
> A: [EMAIL PROTECTED]
> Oggetto: Problem getting value from the request!
>
> Hello everyone,
>
> I wrote a simple servlet application which take the user input from a
> web page and return it to a html page.
> The problem is by testing if the value is null or not.
> It suppose to return some massage if the value is null, let's say "No
> value" and the value, if it's not null.
> Here is some source code :
>
> import java.io.*;
> import java.lang.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class EinfachesServlet extends HttpServlet{
>
> public void doPost (HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, IOException {
>
> response.setContentType("text/html");
>
> PrintWriter out = response.getWriter();
>
> out.println("<HTML><HEAD><title>Example</title></HEAD>" + "<body
> bgcolor=FFFFFF>");
>
> out.println("<table >");
> out.println("<tr>");
> out.println("<th></th>");
> //out.println("<th></th>");
> out.println("</tr> ");
> out.println("<tr> ");
>
> String NAME = request.getParameter("Name" );
> String Result = "No value";
>
> if (NAME==null){
> out.println("<td>"+ Result.toString() + "</td> ");
> } else {
> out.println("<td>Name entered:"+NAME.toString()+ "</td>");
> }
>
> out.println("</tr>");
> out.println("<tr>");
>
> String DATE = request.getParameter("Datum");
>
> if (DATE !=null){
> out.println("<td>Date entered:"+ DATE + "</td>");
> } else {
> out.println("<td>No value</td>");
> }
> out.println("</tr>");
> out.println("</table> ");
>
> out.println("Return to: <A HREF=../Projekt.html>Projekt </A>");
>
> out.println("</body></HTML>");
> out.close();
> }
> }
>
> If there is not input I get the message "Name entered: " instead of "No
> value".
> What should I change ? The first time I used ...if (Name != null) {...do
> something} just like the second part with the date.
> The second time I tried to make an Object using the new(String Name =
> new String(request.getParameter("Name") )
> but it steel didn't work fine.
> Please send me some solutions.
> Thank you very much.
>
> ___________________________________________________________________________
> 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
___________________________________________________________________________
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