blackcompe's Profile User Rating: *****

Reputation: 1155 Grandmaster
Group:
Mentors
Active Posts:
2,553 (0.74 per day)
Joined:
05-May 05
Profile Views:
38,372
Last Active:
User is offline Sep 27 2014 06:29 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
150
Expert In:
Java

Latest Visitors

Icon   blackcompe has not set their status

Posts I've Made

  1. In Topic: Request Dispatcher forward and request attribute

    Posted 26 Sep 2014

    The request has the POST/GET parameter, so if you pass it to the dispatcher, it'll still be there (I think anyways). No need to use sessions. If you do however, it's:

    HttpServletRequest.getSession.setAttribute()
    
    


    The session variable maintains its information throughout the entire browsing session.
  2. In Topic: use the data read from the file to create instances?

    Posted 10 Sep 2014

    I'd first work trying to read the lines of the file and printing them to the console. Use Scanner.hasNextLine. E.g.

    while(input.hasNextLine()) System.out.println(input.nextLine());
    
    


    Unfortunately, the file format is a bit ackward, so you need to do the following: for each iteration of the loop, read six lines and create a product from them.

    while(input.hasNextLine()) 
    {
    	Product p = new Product();
    	p.setProductCode(input.nextLine());
    	p.setProductName(input.nextLine());
    	.
    	.
    	.
    	items[count++] = p;
    }
    
    


    Edit: I didn't see the ProductLister class. Follow g00se's advice in combination with the code example above. I'd suggest using a list as well for simplicity if you can modify the lister class. You need to extend the lister class by declaring a subclass of it, or creating a anonymous class in the main method. E.g.

    class ProductInventory
    {
    	public static void main(String[] args)
    	{
    		ProductLister lstr = new ProductListerImpl();
    		lstr.readProducts("Products.txt");
    		lstr.displayProductArray(lstr.items);
    	}
    
    	abstract class ProductLister
    	{
    		abstract void readProducts(String file);
    		.
    		.
    		.
    	}
    
    	class ProductListerImpl extends ProductLister
    	{
    		void readProducts(String file) { /* TODO */ }
    		.
    		.
    		.
    		.
    	}
    }
    
    
  3. In Topic: Java game KeyListener not working in FSEM

    Posted 5 Sep 2014

    Have you reviewed the pre-existing solutions to this problem?
  4. In Topic: Program is working but String Index Out of Range Error

    Posted 5 Sep 2014

    Wrong forum. Moving to Java forums.

    while (lengthOfTheWord >=0)

    The condition is never false, and it is the wrong condition to use. What other variable should you consider?
  5. In Topic: Servlet url issue

    Posted 8 Aug 2014

    Why do you expect a servlet to run when you put in the URL for web.xml (a configuration file) ? I suggest you have a look at the Java 6 EE docs, which will help you to understand what's happening.

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
August 22
Gender:
Interests:
Programming, PC Hardware, Cars, Running, Basketball, Weight lifting, Good Music, Video Games
Years Programming:
7
Programming Languages:
Java, C\C++, HTML, SQL, MIPS Assembly, PHP, Javascript, Octave, Ruby, Java EE, Eclipse, CodeBlocks

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Comments

Page 1 of 1
  1. Photo

    jon.kiparsky Icon

    11 Jul 2013 - 07:32
    Hey, good to see you again. Hope you've been well.
  2. Photo

    WolverineX Icon

    13 Nov 2012 - 12:20
    Cool!
  3. Photo

    vbabey Icon

    14 Aug 2012 - 21:21
    Thank you for your advice on file handling question I asked...
  4. Photo

    karniv0re Icon

    14 Apr 2012 - 21:24
    thanks man, if it wasn't for you pointing out that line in the exception message, i might have been stuck forever!!
  5. Photo

    smohd Icon

    31 Jan 2012 - 04:00
    Congratulation for the promotion, well deserved :)
  6. Photo

    jon.kiparsky Icon

    27 Dec 2011 - 08:26
    I've been meaning to say - good stuff in the Java forum. You know your stuff and you tell it well. It's a pleasure to read - keep it up.
  7. Photo

    anonymous26 Icon

    01 Oct 2011 - 12:46
    Excellent! :)
  8. Photo

    anonymous26 Icon

    28 Sep 2011 - 12:59
    Wow! We have the same birth date! Congrats on the Expert badge. :)
Page 1 of 1