• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp scriptlet

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....>
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic