Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2005, 09:13 AM
ejmelious ejmelious is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Pennsylvania
Posts: 306 ejmelious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 21 h 41 m 37 sec
Reputation Power: 9
java.sql.SQLException: Cursor position not valid error

HI all, I have been working on creating applications using DAO's. I am finally starting to get the hang of it. However I am running into this error:

java.sql.SQLException: Cursor position not valid

here is the full stack trace:

Code:
java.sql.SQLException: Cursor position not valid.
	at com.ibm.as400.access.JDError.throwSQLException(JDError.java:382)
	at com.ibm.as400.access.JDError.throwSQLException(JDError.java:359)
	at com.ibm.as400.access.AS400JDBCResultSet.getValue(AS400JDBCResultSet.java:3589)
	at com.ibm.as400.access.AS400JDBCResultSet.getString(AS400JDBCResultSet.java:3230)
	at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:174)
	at leftMenu.LeftDAO.logo(LeftDAO.java:80)
	at leftMenu.Left.doGet(Left.java:42)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:419)
	at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:133)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:673)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:464)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
	at BgLeftMnu.doGet(BgLeftMnu.java:58)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.jav  a:738)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Unknown Source)


So Line 80 of LeftDAO is:
Code:
try
		{
			conn = ds.getConnection();
			CallableStatement cs = conn.prepareCall(LOGO);

			ResultSet rs = cs.executeQuery();

			String logo = rs.getString(1); LINE 80

			System.out.println(logo);

			rs.close();
			return logo;
		}


line 42 of Left is:
Code:
String bgLogo = dao.logo(); LINE 42
System.out.println("bgLogo" + bgLogo);
request.setAttribute("bgLogo", bgLogo);


and finally line 58 of BgLeftMnu:
Code:
RequestDispatcher rd = request.getRequestDispatcher("/servlet/Left");
rd.forward(request, response);


Anyone have any suggestions as to how I can clear this up?

I have another question when this is solved, but I cannot get to it until this problem is resolved.

Thanks for the help everyone!!

Reply With Quote
  #2  
Old June 30th, 2005, 09:33 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 10,135 Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 4 Days 1 h 22 m 45 sec
Reputation Power: 5052
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
PHP Code:
 ResultSet rs cs.executeQuery();
if (
rs.next()) { // <-----
    
String logo rs.getString(1); 
    
// do stuff with logo...

__________________
Yawmark
class Sig{public static void main(String...args){\u0066or(int
\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray()
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
+(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}

Reply With Quote
  #3  
Old June 30th, 2005, 09:35 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 10,135 Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 4 Days 1 h 22 m 45 sec
Reputation Power: 5052
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
Explanation: you have to advance the cursor to the first record of the result set. The call to next() will return false if the query returns no rows.

The Java™ Tutorial - Trail: JDBC™ Database Access

Reply With Quote
  #4  
Old June 30th, 2005, 09:41 AM
ejmelious ejmelious is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Pennsylvania
Posts: 306 ejmelious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 21 h 41 m 37 sec
Reputation Power: 9
alright I didnt realize I had to advance to the first result set if there was only one result being returned(why I thought that I will never know)...but I guess it makes sense.

Thanks I will go fix this then come back and ask my second question!

Reply With Quote
  #5  
Old June 30th, 2005, 10:00 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 10,135 Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 4 Days 1 h 22 m 45 sec
Reputation Power: 5052
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
Quote:
alright I didnt realize I had to advance to the first result set if there was only one result being returned(why I thought that I will never know)...but I guess it makes sense.
It's because the cursor actually starts out before the first row (if there is at least one row returned). If the cursor started out on the first row, it'd be a quite a situation if your query didn't return any rows...

Reply With Quote
  #6  
Old June 30th, 2005, 10:21 AM
ejmelious ejmelious is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Pennsylvania
Posts: 306 ejmelious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 21 h 41 m 37 sec
Reputation Power: 9
ok that is all set and works great. I think I have a good model set up for this particular application...I will find out soon though. What I need to do with this part of my applications is very similar to what I did a while ago(I posted about creating a drop down menu that would be populated at runtime with the results of a stored procedure)

This time however, I do not need to populate a drop down menu, I need to create something like an unordered list. This is the scenario: I am working with a framset. The top frame has a horizontal menu with 4 options. When one of the options is clicked another menu is supposed to appear in the left frame. This is to be a vertical menu.

I have the horizontal menu created (it was a string returned to me from a stored procedure that I just inserted into the html). When I click on the option I call the required stored procedures and I get the results, but again I am not sure how to take the result set and have it displayed on the html page.

Each result is just a string of code that needs to be placed in the html to create the unordered list (at least thats what I was thinking, it does not have to be an unordered list, if there is an easier way thats great!)

ok so that is what I want to do here is the code I will list it all:

First Left.java:
Code:
package leftMenu;

import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import javax.naming.*;
import javax.naming.directory.*;

public class Left extends HttpServlet
{
	public static final String PATH = "/bgLeft.jsp";

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
    	String resultPath = PATH;

    	HttpSession session = request.getSession(true);

		String sessId = (String) session.getAttribute("id");
		String xmq = (String) session.getAttribute("xmq");
		String ymb = (String) session.getAttribute("ymb");

		try
		{
			Context initCtx = new InitialContext();
			Context envCtx = (Context) initCtx.lookup("java:comp/env");
			DataSource ds = (DataSource) envCtx.lookup("jdbc/myDataSource");

          	LeftDAO dao = new LeftDAO(ds);
this is the list of menu items that need to be displayed
          	List items = dao.menuItems(sessId, xmq, ymb);
          	System.out.println("items:" + items);
          	request.setAttribute("items", items);
this is the logo that I will display at the bottom of the frame
          	String bgLogo = dao.logo();
          	System.out.println("bgLogo: " + bgLogo);
          	request.setAttribute("bgLogo", bgLogo);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

		RequestDispatcher rd = request.getRequestDispatcher(resultPath);

		rd.forward(request, response);

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
    	doGet(request, response);
    }
}


Now Left.DAO.java
Code:
package leftMenu;

import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import javax.naming.*;
import javax.naming.directory.*;

public class LeftDAO
{
	static final String LEFT = "{call wmsguitst.BGGETLFTM1(?,?,?)}";
	static final String LOGO = "{call wmsguitst.BGGETLOGO1()}";

	private DataSource ds;

	public LeftDAO(DataSource ds)
	{

    	if (ds == null)
    	{
    		throw new NullPointerException("data source cannot be null");
    	}
    	this.ds = ds;
	}
 again this it where the menu items are accessed fromthe the stored proceudre
	public List menuItems(String sessId, String xmq, String ymb) throws SQLException
	{
		Connection conn = null;

		try
		{
			conn = ds.getConnection();
			CallableStatement cs = conn.prepareCall(LEFT);

			cs.setString(1, sessId);
			cs.setString(2, xmq);
			cs.setString(3, ymb);

			ResultSet rs = cs.executeQuery();

			List items = new ArrayList();

			while(rs.next())
			{
				String item = rs.getString(1);
				items.add(new Item(item));
			}
			rs.close();
			return items;
		}
		finally
		{
			if (conn != null) conn.close();
		}
	}
 and again this stored proceudre returns just a string referencing a logo
	public String logo() throws SQLException
	{
		Connection conn = null;

		try
		{
			conn = ds.getConnection();
			CallableStatement cs = conn.prepareCall(LOGO);

			ResultSet rs = cs.executeQuery();

			String logo = null;

			if(rs.next())
			{
				logo = rs.getString(1);
			}

			rs.close();
			return logo;
		}
		finally
		{
			if (conn != null) conn.close();
		}
	}
}


and finally Item.java
Code:
package leftMenu;

import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import javax.naming.*;
import javax.naming.directory.*;

public class Item
{
	private String item;

	public Item(String item)
	{
		this.item = item;
	}

	public String getItem()
	{
		return item;
	}
}


Sorry this was so long...if you need a better explanation of what is going on I can attempt to provide one...

Thanks for your time!

Reply With Quote
  #7  
Old June 30th, 2005, 10:35 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 10,135 Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 4 Days 1 h 22 m 45 sec
Reputation Power: 5052
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark

Reply With Quote
  #8  
Old June 30th, 2005, 10:51 AM
ejmelious ejmelious is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Pennsylvania
Posts: 306 ejmelious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 21 h 41 m 37 sec
Reputation Power: 9
looks like it is time to hit the books again....

can you just tell me if my design so far is adaquate..I modeled it after what was created for my previous application, I just modified it for this one...

thanks

Reply With Quote
  #9  
Old June 30th, 2005, 11:20 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 10,135 Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 4 Days 1 h 22 m 45 sec
Reputation Power: 5052
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
If it works the way you want it to, it's adequate!

Reply With Quote
  #10  
Old June 30th, 2005, 11:27 AM
ejmelious ejmelious is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Pennsylvania
Posts: 306 ejmelious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 21 h 41 m 37 sec
Reputation Power: 9
HAHA...that is the greatest reply I have ever seen...

Reply With Quote
  #11  
Old June 30th, 2005, 12:32 PM
ejmelious ejmelious is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Pennsylvania
Posts: 306 ejmelious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 21 h 41 m 37 sec
Reputation Power: 9
Do you have any different tutorials, those did not help me much with this specific taks. Maybe any with examples...I was not able to find much on google either....

Thanks

Reply With Quote
  #12  
Old June 30th, 2005, 12:56 PM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 10,135 Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 4 Days 1 h 22 m 45 sec
Reputation Power: 5052
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
I don't believe that it took you only two hours to complete each of those tutorials or understand the information contained within them. It's going to be tough to find a tutorial that will spell out exactly what you need to do each step of the way - you'll have specific requirements that need to be met, and that's perfectly natural. Rather, the tutorials are designed to provide you with a foundation so you can make choices about how to implement your ideas in Java.

See if this one helps close any gaps.
The J2EE™ Tutorial - JavaServer Pages Technology

If that doesn't help, there's always Google...
http://www.google.com/search?q=jsp+jdbc+tutorial

Reply With Quote
  #13  
Old June 30th, 2005, 01:15 PM
ejmelious ejmelious is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Pennsylvania
Posts: 306 ejmelious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 21 h 41 m 37 sec
Reputation Power: 9
alright here is one specific question I have. If I figure this out I should be able to do this I hope...

ok the way I am going to do this, I want to pass the List items as an attribute so it can be used by the jsp. Can I actually pass it as a list as such:

Code:
 List items = dao.menuItems(sessId, xmq, ymb);
          	request.setAttribute("items", items);


in otherwords does that pass the List as a string or as a list. Also if I had an array and I attempted to set it as an attribute does that need anything special or can I just do it like the above example.

secondly, when attempting to access these in the jsp this is how I was planning on going about it:
Code:
string[] listedItems = request.getAttribute("items")
will that store the items in an array??

Thats mainly what I am hung up on right now, I know how to run through it when I eventually get to it, but right now I am not sure how to get to it.....

I hope this is clear enough


Thanks!

Reply With Quote
  #14  
Old June 30th, 2005, 01:24 PM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 10,135 Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level)Yawmark User rank is General 61st Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 4 Days 1 h 22 m 45 sec
Reputation Power: 5052
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
Quote:
in otherwords does that pass the List as a string or as a list.
It gets passed as a List.
Quote:
Also if I had an array and I attempted to set it as an attribute does that need anything special or can I just do it like the above example.
It's just like the List.
Quote:
will that store the items in an array??
No. You'll need to get the same type of object back. Example:
PHP Code:
List items = (List) request.getAttribute("items");
// or...
String[] items = (String[]) request.getAttribute("items");
// depending on what type of reference was set... 
This is exactly the sort of thing that you'll learn how to do when you read the tutorials. In all seriousness, it seems like a waste of time and bandwidth to repeat information here that's covered in the introductory tutorials and the API. I certainly don't mind helping, but you'll need to improve your research habits if you wish to grow in your programming skills. I don't want to discourage you from asking for help, but you can very often find your own answers by doing a little research and writing a lot of code (that's how I learned, so I'm speaking from experience).

Good luck!

Reply With Quote
  #15  
Old June 30th, 2005, 01:34 PM
ejmelious ejmelious is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Pennsylvania
Posts: 306 ejmelious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 21 h 41 m 37 sec
Reputation Power: 9
I understand that research is valuable and that learning how to code by trying and trying it until I finally get it can be a valuable learning tool, but what would have taken me hours to read through everything and learn you answered in 3 minutes. I learned everything else by reading, it was just that one thing that I did not see out in the open, I figured instead of digging and digging I would ask because if someone knew that answer, why should I waste my time looking and killing myself...I know that sounds selfish and I am sorry it comes across that way, I am just going for the most effective time efficient solution, and now I know how to do it and thats what I needed.

So I do read the tutorials, but I also do ask a lot of questions. I do not ask questions to be a pain or to inconvenience anyone, but if the answer is readily available you will have a hard time convincing me that hours and hours of reading for one answer is better than asking.

Please do not be upset by this response, I just didnt want you to think I come ask for questions and that is it, I have learned more from this forum than I could have ever imagined. I have great respect for everyone in here and do not wish to upset anyone.

Again, thanks for you time!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > java.sql.SQLException: Cursor position not valid error

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap