Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Retrieve data from database in JSP(simple CRUD)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello! I just started learning Java EE, created simple MySQL DB and decided to retrieve DB data in JSP page using servlets. But nothing shows up, only table headers. Although printed out everything to the console using main method, just to make sure that the getAll() method in DAO layer works. Could you please tell me what am I doing wrong here:

Controller Servlet:


web.xml:



index.jsp:

Untitled.jpg
[Thumbnail for Untitled.jpg]
 
Sheriff
Posts: 67699
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your web.xml is wrong. It shouldn't be using the old DOCTYPE. See the JspFaq (this one: https://coderanch.com/how-to/java/ElOrJstlNotWorkingAsExpected) for information on properly setting up the web.xml.
 
Bear Bibeault
Sheriff
Posts: 67699
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should also be declaring your JSP/HTML as HTML5, not HTML4. You are apparently using some pretty old and dated source material.
 
Serge Pietel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You should also be declaring your JSP/HTML as HTML5, not HTML4. You are apparently using some pretty old and dated source material.



Thanks for quick response, I changed my web.xml specifying HTML5 in it, but it didn't help, same output:( Currently reading Head First JSP & Servlets.
 
Bear Bibeault
Sheriff
Posts: 67699
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The HTML5 declaration is for the HTML (generated by the JSP) and has nothing to do with the web.xml.

Read the FAQ I linked to; it will show you how to properly configure the web.xml.
 
Serge Pietel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

The HTML5 declaration is for the HTML (generated by the JSP) and has nothing to do with the web.xml.

Read the FAQ I linked to; it will show you how to properly configure the web.xml.



Thanks, I read it... Probably the problem was with my Eclipse's workspace: I deleted one messy project in it, reconfigured Tomcat server and cleaned my project and it works!
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic