• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp scriptlet

 
Hari Venkat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all i have come up with one more silly question,

When the follwing scriptlet is executed, output is :

[{property=Date}, {property=Campaign}, {property=Banner}, {property=Impressions}, {property=Clicks}, {property=CTR}]
My requirement is that output should be only Date, Campaign and so on..
Can any one help me out..
Thanks in advance..
Here is my code:

<jsp:scriptlet>
out.println(session.getAttribute("col"));
</jsp:scriptlet>

Here is my createReport code:
ResultSet rs = cs.getResultSet();

ResultSetMetaData metadata = rs.getMetaData();
int colCount = metadata.getColumnCount();
RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);

java.util.List colNameSet = new java.util.ArrayList();

for(int i=1;i<colCount;i++){
java.util.Map x1 = new java.util.HashMap();
String temp=(String)metadata.getColumnName(i);
x1.put("property",temp);
colNameSet.add(x1);
}

session.setAttribute("col", colNameSet);
session.setAttribute("results", resultSet);

request.getRequestDispatcher("viewdata.jsp").forward(request,response);

Now can u explai me how to get only names by using scriptlet or anyother way.. I need this because, i need to send it as value while using checkbox....>
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What this code produces is a List of Map objects, all having one entry: property=[columnName]

If all you want is a list of columnNames, then thats all you should add to the colNameSet variable. Why are you using a Map at all?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javaranch tip:

If you are going to post more than a line or two of your code, wrap that
code in a set of UBB Code tags.
Doing so will help to preserve your code's indenting, making it easier to read.
If it is easier to read, more people will actaully read it and you will
stand a better chance of getting help with your question.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!