Java basic web page not working

Posted on 2012-04-11
Last Modified: 2012-06-21
I'm experienced using Classic ASP and ASP.NET but new to Eclipse and JSP.  Though very similar to Classic ASP I'm unable to get a basic example to work.  My code is a simple learning tool which is comprised of a class and method that returns a string array.  My webpage then iterates this returned object and loads a table's rows.  

The problem is that no values are ever recieved on the page.  The code always completes with empty rows.  What am I missing here?

//String array class
public class ResultLookup {

	//Class declarations

	//Class constructor
	public ResultLookup() throws SQLException, IOException
	//Return a simulated dataset
	public String[] GetResultSet()
		//Local declarations
		String[] strResultArray = new String[5];
		//Setup string array
		strResultArray[0] = "Sample text";
		strResultArray[1] = "A short placeholder";
		strResultArray[2] = "Slightly longer placholder";
		strResultArray[3] = "This code look just like Classic ASP";
		strResultArray[4] = "JSP the Hundia to ASP.NET's Honda";
		//Return result
		return strResultArray;

//Web page to display my data
<table border="1">
		ResultLookup objResultLookup = new ResultLookup();
		String[] strResults;
		strResults = objResultLookup.GetResultSet();

		for (int i = 0; i < strResults.length; i++)
			<% strResults[i].toString(); %>
	catch (Exception ex)
		System.out.print("An TestResults.jsp error has occurred!");

Open in new window

Question by:Phil5780
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

ioanton earned 500 total points
ID: 37834387
Try replacing

<% strResults[i].toString(); %>

Open in new window


<%= strResults[i].toString() %>

Open in new window


Author Closing Comment

ID: 37835207
Great! This was my problem.  JSP feels just like Classic ASP scripted with C#.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
String format issue 13 93
oracle fusion vs MQ 2 128
Unhandled exception type Exception 18 52
by zero exception 10 70
Building a cohesive image for your brand is vital to making an impression on consumers. When the economy is tough, brands do better than unbranded  products. This can have a huge impact on your long-term profits, as the economy goes up and down.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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