aspose file tools*
The moose likes JSP and the fly likes creating textbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "creating textbox" Watch "creating textbox" New topic
Author

creating textbox

Mayank Yadav
Greenhorn

Joined: Aug 30, 2006
Posts: 4
hi..iam very new to jsp, i would like to know how to fetch a value entered in a text box, check box and then display it after clicking a button...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

"my self",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

What code have you written so far?
Mayank Yadav
Greenhorn

Joined: Aug 30, 2006
Posts: 4
<HTML>
<HEAD>
<TITLE>Submitting Text Fields</TITLE>
</HEAD>

<BODY>
<H1>Submitting Text Fields</H1>
<FORM ACTION="formAction.jsp" METHOD="POST">
Please enter your name:
<INPUT TYPE="TEXT" NAME="text1">
<BR>
<INPUT TYPE="SUBMIT" value="Submit">
<% out.println(request.getParameter("text1")); %>

</FORM>
</BODY>
<HTML>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

What is the purpose of the out.print statement in this form html?

Since the form has yet to be submitted, it's got nothing to show.
Mayank Yadav
Greenhorn

Joined: Aug 30, 2006
Posts: 4
After clicking the submit button the text written in the textbox should be displayed in the page ...so how should i do this..??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

When you click the submit button control will be passed to the JSP page in the action attribute of the form. Is that another page or this same page?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Before going any further, I'd highly recommedn that you read this article.
Mr. Ravi Yadav
Greenhorn

Joined: May 24, 2011
Posts: 3
Mayank Yadav wrote:<HTML>
<HEAD>
<TITLE>Submitting Text Fields</TITLE>
</HEAD>

<BODY>
<H1>Submitting Text Fields</H1>
<FORM ACTION="formAction.jsp" METHOD="POST">
Please enter your name:
<INPUT TYPE="TEXT" NAME="text1">
<BR>
<INPUT TYPE="SUBMIT" value="Submit">
<% out.println(request.getParameter("text1")); %>

</FORM>
</BODY>
<HTML>



Question : What if we want to do the same thing (print the "text1" on console) in "Servlet".
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Java code in a JSP? In 2011? Really?

And, as the value of text1 can't be known until after the JSP executes and the page is sent to the browser where the user can enter the value, there is no way to do this.

I suggest you read this article to understand what JSP is and how it works.

Mr. Ravi Yadav
Greenhorn

Joined: May 24, 2011
Posts: 3
Bear Bibeault wrote:Java code in a JSP? In 2011? Really?

And, as the value of text1 can't be known until after the JSP executes and the page is sent to the browser where the user can enter the value, there is no way to do this.

I suggest you read this article to understand what JSP is and how it works.




What if the text1 is hard coded say like :
<INPUT TYPE="TEXT" NAME="text1" VALUE="My Value">

P.S : I know it might be a silly question, however I wanted to clear this point.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Still no. To the JSP engine the HTML markup is just template text. It makes as much sense to the JSP engine as wufgwukrfwrfgkuwgfrgfkwrkdkdwgckw.

Have you read the article?
 
 
subject: creating textbox