Capture login information and pass to Java method

I hope this is a simple question.  I know Java, but I've just started learning JSP, and I'm having a difficult time understanding how I can capture the username and password from a login page to pass it to my java method.  I was able to create a variable linking to a samplemethod

Sample.SampleMethod sm = new Sample.SampleMethod();
String jason = sm.test("Input String");

but how would I do the same for the following?

<td class="formPromptTd">User Name:</td>
<td class="formReqTd">*</td>
<td class="formElementTd"><input type="text" name="USERNAME" size="20" tabindex=1 Class="formText"></td>
</tr>


Thanks in advance
jhughes4Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
file1.jsp
--------------------

<form action="file2.jsp">
    <table>
        <tr>
            <td class="formPromptTd">User Name:</td>
            <td class="formReqTd">*</td>
            <td class="formElementTd"><input type="text" name="USERNAME" size="20" tabindex=1 Class="formText"></td>
        </tr>
    </table>
</form>

file2.jsp
--------------------
<%
    String username = request.getParameter( "USERNAME" ) ;
    out.println( "<h1>The user entered the username" + username + "</h1>" ) ;
%>
0
TimYatesCommented:
SOrry, file1.jsp should be:

<form action="file2.jsp">
    <table>
        <tr>
            <td class="formPromptTd">User Name:</td>
            <td class="formReqTd">*</td>
            <td class="formElementTd"><input type="text" name="USERNAME" size="20" tabindex=1 Class="formText"></td>
        </tr>
        <tr>
            <td colspan="3">
                <input type="Submit" value="OK">
            </td>
        </tr>
    </table>
</form>
0
jhughes4Author Commented:
Thanks for the quick response.  

If I wanted to pass say both username and password to a java method would I do the following?
<form action="sample"> //for username
<form action="sample"> //for password

assuming that sample.class is in my classpath?

sorry, but I had one other question.  In Java if a method has input paramters of both String and int I would do the following:

Sample.SampleMethod sm = new Sample.SampleMethod();
String jason = sm.test("Input String", 10);

How would I do this with form action?  I've increased the points since I've asked additional questions.  thanks again.

0
TimYatesCommented:
> If I wanted to pass say both username and password to a java method would I do the following?

Nope, just put 2 input boxes inside the main form:

        <tr>
            <td class="formPromptTd">User Name:</td>
            <td class="formReqTd">*</td>
            <td class="formElementTd"><input type="text" name="USERNAME" size="20" tabindex=1 Class="formText"></td>
        </tr>
        <tr>
            <td class="formPromptTd">Password:</td>
            <td class="formReqTd">*</td>
            <td class="formElementTd"><input type="password" name="PASSWORD" size="20" tabindex=1 Class="formText"></td>
        </tr>
0
TimYatesCommented:
>  In Java if a method has input paramters of both String and int I would do the following:

You can just call java methods direct fomr the JSP:

<%
    Sample.SampleMethod sm = new Sample.SampleMethod();
    String jason = sm.test("Input String", 10);
%>

as request.getParameter() returns a String, you have to do a bit of tweaking ;-)

<%
    String a = request.getParameter( "inputstring" ) ;
    String b = request.getParameter( "anIntValue" ) ;
    int ib = 0 ;
    if( b != null )
        ib = Integer.parseInt( b ) ;
    Sample.SampleMethod sm = new Sample.SampleMethod();
    String jason = sm.test( a, ib );
%>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.