[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Easy help required

Posted on 2005-04-22
14
Medium Priority
?
206 Views
Last Modified: 2010-04-01
Hi All,
I would like an example of a basic jsp page which does the following
Provides a textarea or div for the user to type in some message and when they click submit i want that message to appear
on the page?
can anyone help me with an example?
0
Comment
Question by:archrajan
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 8

Expert Comment

by:koppcha
ID: 13842381
You want it to appear in the same JSP or another JSP
0
 
LVL 25

Author Comment

by:archrajan
ID: 13842393
Same JSP
Thanks!
0
 
LVL 26

Expert Comment

by:Tomas Helgi Johannsson
ID: 13842401
Hi!

Check out this tutorial. You could do it similar to this example.

http://www.jsptut.com/Forms.jsp

Regards,
  Tomas Helgi
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 29

Expert Comment

by:bloodredsun
ID: 13842412
form1.jsp
------------------
<html>
<head><title>Form1</title></head>
<body>

<form name="form1" action="form1.jsp">

<textarea name="area"></textarea>

<input type="Submit" value="Submit">
</form>

<%= request.getParameter("area")%>

<body>
</html>
0
 
LVL 8

Expert Comment

by:koppcha
ID: 13842461
Myform.jsp
--------------------
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<form action="/Myform.jsp" method="get" name="myForm">
First name:
<input type="text" name="fname" />
<br />
Last name:
<input type="text" name="lname" />
<br />
<input type="submit" value="Submit" />

</form>
First name: <%= request.getParameter("fname") %>
Last name:  <%= request.getParameter("lname") %>


</BODY>
</HTML>
0
 
LVL 25

Author Comment

by:archrajan
ID: 13842553
bloodredsun,
when i first load the page i get null?

koppcha,
i will try ur solution
0
 
LVL 25

Author Comment

by:archrajan
ID: 13842570
Well also, when i submit again the first one gets erased!
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13842588
>>when i first load the page i get null?

yes, as no parameter exists yet


----
new version allowing for null parameter checking
---

<html>
<head><title>Form1</title></head>
<body>

<form name="form1" action="form1.jsp">

<textarea name="area"></textarea>

<input type="Submit" value="Submit">
</form>

<%
 String param = request.getParameter("area") != null ? request.getParameter("area") : "" ;
 out.println(param) ;
 %>

<body>
</html>
0
 
LVL 25

Author Comment

by:archrajan
ID: 13842601
Thanks,
is there any way i can have the previous messages also on the page?
0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 2000 total points
ID: 13842623
>>Well also, when i submit again the first one gets erased!

Do you want one that adds it on? Why didn't you say?!

---------------
<html>
<head><title>Form1</title></head>
<body>
<form name="form1" action="form1.jsp">
<textarea name="area"></textarea>
<input type="Submit" value="Submit">
</form>

<%
 String param = request.getParameter("area") != null ? request.getParameter("area") : "" ;
 String sessionParam = (String)session.getAttribute("param") != null ? (String)session.getAttribute("param") : "" ;
 sessionParam += param ;
 session.setAttribute("param" , sessionParam) ;
 out.println(sessionParam) ;
%>

<body>
</html>

-----------
anything else?
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13842626
The above example shows the use of both the request object and the session object in storing and retrieving data. You need to know the difference...
0
 
LVL 25

Author Comment

by:archrajan
ID: 13842640
Thanks! Thats it!
sorry if i did not ask correctly!
0
 
LVL 25

Author Comment

by:archrajan
ID: 13842650
well, thanks for the explanation
seems interesting and cool!
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13842662
No probs archrajan, happy to help :-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Will the future of mobile app development include the same trends as those most relevant today? Find out by checking out the 7 trends of the future.
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question