aspose file tools*
The moose likes JSP and the fly likes how to assign variable in text area? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to assign variable in text area?" Watch "how to assign variable in text area?" New topic
Author

how to assign variable in text area?

karthik ekantha
Ranch Hand

Joined: Feb 08, 2012
Posts: 78
how can assign textarea in the <%= add> is not working in the jsp page .it ll not working



<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="java.sql.*"%>
<!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=ISO-8859-1">
<title>Personnel Details</title>
</head>
<body>
<center>
<%!

String name="";
String fname="";
String mno="";
String comp="";
String add="";
String City="";
String States="";
%>
<%

HashMap personalDetailsMap2 = (HashMap)session.getAttribute("paramlist");


if(personalDetailsMap2.get("name")!=null && personalDetailsMap2.get("name")!="")
{


name = personalDetailsMap2.get("name").toString();
fname=personalDetailsMap2.get("fname").toString();
mno=personalDetailsMap2.get("mno").toString();
comp=personalDetailsMap2.get("comp").toString();
add=personalDetailsMap2.get("add").toString();
City=personalDetailsMap2.get("City").toString();
States=personalDetailsMap2.get("States").toString();
}

%>

<%if(session.getAttribute("paramlist").equals(null)) {%>


<form action="/person/Person" method="post">

<tr><td colspan=2 style="font-weight:bold;" align="center"> User Information<br></td></tr>
<tr><td colspan=2 align="center" height="10px"></td></tr>
<tr><td>NAME </td><td><input type="text" name="name" value="name"><br></td></tr>
<tr><td>FatherName </td><td><input type="text" name="fname" value="fname"><br></td></tr>
<tr><td>MobileNO </td><td><input type="text" name="mno" value="mno"><br></td></tr>
<tr><td> Company </td><td><input type="text" name="comp" value="comp"><br></td></tr>
<tr><td>Address </td><td> <textarea type="text" name="add" value="add"></textarea><br></td></tr>

City:
<select name="City">
<option value="Bangalore">Bangalore</option>
<option value="Chennai">Chennai</option>
<option value="Hyderbad">Hyderbad</option>
<option value="Mumbai">Mumbai</option>
</select>
<br>

States:
<select name="States">
<option value="Kanataka">Kanataka</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andrapradesh">Andrapradesh</option>
<option value="Maharastra">Maharastra</option>
</select><br>

<input type="submit" name="b1" value="Save" >
<input type="submit" name="b1" value="Edit"> <br>

</form>

<% } else {%>
<form action="/person/Person" method="post">

<tr><td colspan=2 style="font-weight:bold;" align="center"> User Information<br></td></tr>
<tr><td colspan=2 align="center" height="10px"></td></tr>
<tr><td> NAME </td><td><input type="text" name="name" value=<%= name%>><br></td></tr>
<tr><td>FatherName </td><td><input type="text" name="fname" value=<%= fname%>><br></td></tr>
<tr><td>MobileNO </td><td><input type="text" name="mno" value=<%= mno%>><br></td></tr>
<tr><td> Company </td><td><input type="text" name="comp" value=<%= comp%>><br></td></tr>
<tr><td>ADDRESS </td><td> <textarea type="text" name="add" value=<%= add%>></textarea><br></td></tr> how can specify text area ??? this is not working

City:

<% if( City.equals("Bangalore")) {%>
<select name="City">
<option value="Bangalore" selected = "selected">Bangalore</option>
<option value="Chennai">Chennai</option>
<option value="Hyderbad">Hyderbad</option>
<option value="Mumbai">Mumbai</option>
</select>
<% } %>
<% if( City.equals("Chennai")) {%>
<select name="City">
<option value="Bangalore" >Bangalore</option>
<option value="Chennai" selected = "selected">Chennai</option>
<option value="Hyderbad">Hyderbad</option>
<option value="Mumbai">Mumbai</option>
</select>
<% } %>
<% if( City.equals("Hyderbad")) {%>
<select name="City">
<option value="Bangalore" >Bangalore</option>
<option value="Chennai" >Chennai</option>
<option value="Hyderbad"selected = "selected">Hyderbad</option>
<option value="Mumbai">Mumbai</option>
</select>
<% } %>
<% if( City.equals("Mumbai")) {%>
<select name="City">
<option value="Bangalore" >Bangalore</option>
<option value="Chennai" >Chennai</option>
<option value="Hyderbad">Hyderbad</option>
<option value="Mumbai"selected = "selected">Mumbai</option>
</select>
<% } %>
<br>

States:
<% if( States.equals("Kanataka")) {%>
<select name="States">
<option value="Kanataka"selected = "selected">Kanataka</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andrapradesh">Andrapradesh</option>
<option value="Maharastra">Maharastra</option>
</select>
<% } %>
<% if( States.equals("Tamilnadu")) {%>
<select name="States">
<option value="Kanataka">Kanataka</option>
<option value="Tamilnadu"selected = "selected">Tamilnadu</option>
<option value="Andrapradesh">Andrapradesh</option>
<option value="Maharastra">Maharastra</option>
</select>
<% } %>
<% if( States.equals("Andrapradesh")) {%>
<select name="States">
<option value="Kanataka">Kanataka</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andrapradesh"selected = "selected">Andrapradesh</option>
<option value="Maharastra">Maharastra</option>
</select>
<% } %>
<% if( States.equals("Maharastra")) {%>
<select name="States">
<option value="Kanataka">Kanataka</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andrapradesh">Andrapradesh</option>
<option value="Maharastra"selected = "selected">Maharastra</option>
</select>
<% } %>


<br>

<input type="submit" name="b1" value="Save" >
<input type="submit" name="b1" value="Edit"> <br>

</form>
<%}%>

</center>
</body>
</html>
Karthik Ponnusamy
Greenhorn

Joined: Jan 05, 2010
Posts: 7
Hi Karthik,

Please use the below as syntax for using text area in jsp pages.

<input type="textarea" name="textarea" value="Find in Jsp">

in your case it might be,

<tr>
<td>ADDRESS </td>
<td> <input type="textarea" name="add" value=<%= add%>> </td>
</tr>

Please verify & let me know for any suggestions.

Thanks,
Karthik.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

With textarea elements, the value comes between the opening and closing tags:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
karthik ekantha
Ranch Hand

Joined: Feb 08, 2012
Posts: 78
thank you i got it ..thank your response .....
 
Consider Paul's rocket mass heater.
 
subject: how to assign variable in text area?