Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java basic web page not working

Posted on 2012-04-11
2
Medium Priority
?
340 Views
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">
		<tr>
			<td>
				Names
			</td>
		</tr>	
	<%
	
	try
	{
		ResultLookup objResultLookup = new ResultLookup();
		String[] strResults;
		strResults = objResultLookup.GetResultSet();

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

Open in new window

0
Comment
Question by:Phil5780
[X]
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
2 Comments
 
LVL 9

Accepted Solution

by:
ioanton earned 2000 total points
ID: 37834387
Try replacing

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

Open in new window


with

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

Open in new window

0
 

Author Closing Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
In this article, I’ll show how research, determination, and use of modern technology helped me solve a DNA mystery.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 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