Win a copy of Kotlin for Android App Development this week in the Kotlin 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Accessing subcategories with the help of categories in java using jstl  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using java, mysql and glassfish server 4.0

I have two tables in my database

1.category with id and name as its fields 2.subcategory with id and name and category_id which refers to id of category table.

I am fetching all categories on first page and I am trying to access the subcategories related to category on the next page. Here are the code.

 
Saloon Keeper
Posts: 5234
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What, specifically, is missing or not working in this code? Tell us what you tried, and what the result was.
 
Rax Sico
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to access subcategories when I click the category. I want that the subcategories specific to the category which i click get listed on the next page.I am giving the first page code below.

Everything is working fine but the subcategories are not displaying on the next page.

This is first page code. This page is working fine.


 
Master Rancher
Posts: 3887
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


If this check is false then you won't get anything appearing.
Have you checked the values you are comparing here?
Have you tried to display the data without this check?
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell what the SQL being generated is?

From a guess I would think it is:


Which probably won't match any actual category ids in your database.
Now why might that be happening?
 
Dave Tolls
Master Rancher
Posts: 3887
45
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And this is one good reason not to be doing this sort of thing in a JSP page.
The SQL tags really weren't designed for anything other than quick and dirty data provision for demos.

The database access ought to be in some for of data service class(es) that you can write and then test by themselves.
Then a Servlet can provide those service(s) the data from the front end, and get the result and pass that (pre-checked_ data to the JSP.

This allows you to test this stuff far more easily, as well as debug them when you hit an issue.
Debugging a JSP page is painful.
 
Marshal
Posts: 67226
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:And this is one good reason not to be doing this sort of thing in a JSP page.


This is too important not to repeat, so I'll repeat it. A few times.

Dave Tolls wrote:
And this is one good reason not to be doing this sort of thing in a JSP page.
And this is one good reason not to be doing this sort of thing in a JSP page.
And this is one good reason not to be doing this sort of thing in a JSP page.
And this is one good reason not to be doing this sort of thing in a JSP page.
And this is one good reason not to be doing this sort of thing in a JSP page.


Rule of thumb: make the JSPs as dumb as possible. Make the JSPs as simple as possible. Make the JSPs do the absolute minimum to generate the HTML.

Remember, JSPs are supposed to be templates for the HTML, not units of processing.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!