troubleshooting Question

JSP page getting data dynamically

Avatar of micro_learner
micro_learner asked on
JSP
2 Comments2 Solutions225 ViewsLast Modified:
I am new to JSP  but can do a bit of Java ...I am trying out my first JSP Pages


I have a File which I parse at Run time using a Tokenizer and display it in a table ..which I was sucessful ..As I am learning to do this (though the project is a real time one ...in bioinformatics) ..I was wondering if there is a better of way of doing this ..by say using a Java Class which stores the Table in some sort of a HashMap and I get the table on the fly ..at run time .

<div align="center">
<u><font face="Verdana, Arial, Helvetica, sans-serif"><b>Supplementtal Table1</b></font></u>
<br/>
<hr/>
<br/>
<table border=1 width="100%" align="center">
      <TR bgcolor="#B3D8D1">
    <TH ALIGN="LEFT">
    Common Name
    </TH>
    <TH ALIGN="LEFT">
    Expression Value
    </TH>
    <TH ALIGN="LEFT">
    Gene Acession Number
    </TH>
    <TH ALIGN="LEFT">
      Unigene Name
      </TH>
    <TH ALIGN="LEFT">
    GO Biological Process
    </TH>
    <TH ALIGN="LEFT">
    GO Cellular Component
    </TH>
    <TH ALIGN="LEFT">
    G0 Molecular Functions
    </TH>
        </TR>
        
<%
      try{
            int index = 0;
            while((line = in.readLine())!= null) {
                  if (index%2 == 0) {
%>            
      <TR bgcolor="#EFEFEF">
<%                  
                  } else {
%>
      <TR>
<%
                  }
                  st = new StringTokenizer(line, "\t");
                  int count = st.countTokens();
                  if (count == Header.length) {
                      while (st.hasMoreTokens()) {
%>                  
    <TD ALIGN="LEFT">
<%        
                              out.println(st.nextToken());
%>                              
    </TD>
<%      
                        }
                        index++;
                }
%>
      </TR>
<%
            }
            in.close();
      } catch(Exception e) {
            System.out.println("SupplyTable1Results.txt: " +e);
      }
%>
</table>
</div>
</body>
</html>

<%!
      private static final String[] Header = {"Common Name", "Expression Value", "Gene Acession Number",
                  "Unigene Name", "GO Biological Process", "GO Cellular Component", "G0 Molecular Functions"};
%>                  

##########################################################################################
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros