On Jul 3, 1:04 am, Presario 6331RSH HAM <kb9...@gmail.com> wrote:
> Hey all!
>
> I was just trying to modify this demo to take input from the index.jsp
> via a form.
> Now ive gotten it to work somewhat. I mean the index.jsp will send the
> data to the servlet but I'm
> stuck trying to figure out how to just default the war to bring up the
> index.jsp and not the servlet.
> Maybe I'm missing something. I'm going to try taking out the mapping
> for the servlet in the web_xml.
> I'll let you know.
Well that didn't work. I found the problem. The war was fine. It was
in the the Enterprise Application or the EJBDemo itself. It had /
MyServlet set as the relative url. So I removed it and now I get the
result I wanted.
So here is what I did.
First you need an index.jsp here's mine:
<%...@page contentType="text/html"%>
<%...@page pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
        <title>Greeting Page</title>
    </head>
    <body>
        <h1>Please enter your name.</h1>

        <form id="getName" action="MyServlet" method="get">
            <input type="text" id="username" name="username"
size="25">
            <p></p>
            <input type="submit" value="Submit">
            <input type="reset" value="Reset">
        </form>
    </body>
</html>
> I just wanted more than hard coded "Sang Shin" in my servlet ;-)

here is what you need in MyServlet:

after // then write the data of the response
String username = request.getParameter("username");

then change
out.println("<h1>Returned string from Session bean is " +
mySessionBean.sayHello(username)  + "</h1>");
That's it, and it was giving me so much trouble. Whew!! That was fun.
So now you have something like Dukes Birthday(except for web service)
that takes data input from a page form, passes it to the servlet, and
the servlet uses the Enterprise Java Bean "MySessionBean". Now the
triangle is complete.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Java 
EE (J2EE) Programming with Passion!" group.
To post to this group, send email to 
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to 
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to