• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JSP not showing table output

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,
I am trying to get my form input from my AddCustomers_Form to dislpay in a table in my AddCustomers.jsp. I have searched endlessly for help and answers but have not found anything helpful to my situation. I am using Eclipse, WildFly 23, and a Postgres database. My form accepts the user information, stores it in my database, but does not print to the jsp in table form. Since it is stored in the database, I know my Driver works, and my jar files are in the right places so I'm really confused on why I can't get the table to print. So, here is my code and any help would be appreciated.

AddCustomers_Form.jsp


AddCustomersServlet


AddCustomers.jsp


On a side note, I CAN get the table to display is I use the out.println method in the servlet but then I lose all of my css formatting, and the way I have shown above is how I was originally showed how to do it. I will post the other servlet that displays the table and user input below. If this is the correct way to do it then how do I keep my css as well? Thanks in advance.
 
Sheriff
Posts: 28331
97
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nathaniel, welcome to the Ranch!

Your question is a bit unclear. You say that your AddCustomers.jsp doesn't show the table output. I don't know whether that means "it shows the headings but no customers" or "it shows only the headings".

And likewise your servlet with "out.println" in it. It's clear that it doesn't show any customers, but it does show the headings. And you seem to think that's okay. But no, that's not the correct way to do it. Technically it's legal but it's really in bad taste since it's been an obsolete feature for nearly 20 years now.

So I'm guessing your first version shows you nothing, including no heading. I think that's because of this line of code:

Look closely and compare with the line below.
 
Nathaniel Broome
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Hi Nathaniel, welcome to the Ranch!

Your question is a bit unclear. You say that your AddCustomers.jsp doesn't show the table output. I don't know whether that means "it shows the headings but no customers" or "it shows only the headings".

And likewise your servlet with "out.println" in it. It's clear that it doesn't show any customers, but it does show the headings. And you seem to think that's okay. But no, that's not the correct way to do it. Technically it's legal but it's really in bad taste since it's been an obsolete feature for nearly 20 years now.

So I'm guessing your first version shows you nothing, including no heading. I think that's because of this line of code:

Look closely and compare with the line below.



Hello Paul,
Thank you for responding, and I apologize for not being more clear. When I run the program and point towards AddCustomers.jsp it shows only the headings of the table and that's it. Also, are you saying that I need insert the import statement in to theAddCustomers.jsp? I'm just trying to make sure I understand. Thank you for letting me know that my servlet with the "out.println" is way outdated, but the crazy part is that when the AddCustomersServlet is pointed to request.getRequestDispatcher("Display").forward(request, response) it actually prints the table and the user info. I was willing to try anything! Thank you again, I appreciate you!
 
Paul Clapham
Sheriff
Posts: 28331
97
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nathaniel Broome wrote:Also, are you saying that I need insert the import statement in to theAddCustomers.jsp? I'm just trying to make sure I understand.



Now I'm the one being unclear. I'm saying you need to check the spelling of that import statement. Did you really put "ailrines" into the package name of the Customers class while putting "airlines" into the package name of a different class?

(One other thing, not related to your current issue: if you have a class which contains data for a customer then you ought to call that class "Customer" and not "Customers". A class called "Customers" would be expected to contain data about some unknown number of customers.)
 
Saloon Keeper
Posts: 28325
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The use of "out.println()" is simply indicative that you are producing your output HTML by brute programming force. The preferred way these days is to use a JSP as View Template and have the servlet forward to that JSP with the results of its computations. Since the JSP more closely resembles the actual HTML, it's a lot easier to maintain, where out.println() has a lot of java crud code surrounding the actual output HTML.

The opposite offence is to use JSPs with scriptlets, and that, too is discouraged.
 
Nathaniel Broome
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Now I'm the one being unclear. I'm saying you need to check the spelling of that import statement. Did you really put "ailrines" into the package name of the Customers class while putting "airlines" into the package name of a different class?



Well yes, yes I did lol! I didnt even realize that. Thanks for pointing that out. So, I did update all the packages to the same "airlines" but the problem still exists. I feel so defeated. I have been working on this literally since time began.
 
Nathaniel Broome
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:The use of "out.println()" is simply indicative that you are producing your output HTML by brute programming force. The preferred way these days is to use a JSP as View Template and have the servlet forward to that JSP with the results of its computations. Since the JSP more closely resembles the actual HTML, it's a lot easier to maintain, where out.println() has a lot of java crud code surrounding the actual output HTML.

The opposite offence is to use JSPs with scriptlets, and that, too is discouraged.


Thank you, I appreciate your response. I know that jsp pages are the way to go but when I could not get the result I wanted I was willing to try anything to get the end result. So that's the reason I tried it the with the "out.println()".
 
Nathaniel Broome
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hopefully the attachment will be on here for your view.
Screenshot-2023-04-07-093549.png
[Thumbnail for Screenshot-2023-04-07-093549.png]
 
Tim Holloway
Saloon Keeper
Posts: 28325
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are storing the customer list under the session-scope name "customer", but you are referencing "customers" on the JSTL.
 
Paul Clapham
Sheriff
Posts: 28331
97
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nathaniel Broome wrote:I feel so defeated. I have been working on this literally since time began.



When I start trying to learn a totally new programming topic, what I do is to start with a working example which I got from somebody else. A tutorial or whatever. It doesn't particularly have to do what I'm interested in doing, it just has to work correctly. Then I change it, piece by piece, until it does what I want to do. Then when (not if) it stops doing what I expect it do given the changes I made, it's because of the last change I made. Which makes it relatively easy to track down what new thing I need to learn about.
 
Nathaniel Broome
Greenhorn
Posts: 22
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,
I would just like to say thank you for all your help. I had to change a few things in my classes code, as well as the things you helped point out to me, but I got it to work. I appreciate you all actually helping and not making me feel dumb in the process. I appreciate you!
 
There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic