• 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 two pages

 
Ranch Hand
Posts: 48
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to write to pages in JSP to show to professor that i know to search some database (for example northwind from access) and to click on 1 record and then opens second JSP page for selected record and from that page to show report for that selected record (for example for one customer). I am new to JSP but not to servlets and could you help me with this?
 
Sheriff
Posts: 67752
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
All the work should be done in Java classes, not JSP. JSP should only be used to show the final results.

In other words, if you find yourself starting to put java code into a JSP, you are doing it wrong.

So get your Java classes written to perform all the database and other stuff, and then let us know what problems you are having showing results in the JSPs.
 
Ivan Bisevac
Ranch Hand
Posts: 48
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:All the work should be done in Java classes, not JSP. JSP should only be used to show the final results.

In other words, if you find yourself starting to put java code into a JSP, you are doing it wrong.

So get your Java classes written to perform all the database and other stuff, and then let us know what problems you are having showing results in the JSPs.


Yout mean that i have to write servlet class? And after that to write jsp? I worked with servlets but with jsp never. Can you explain me more..
 
Bear Bibeault
Sheriff
Posts: 67752
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
Read this article.
 
Ivan Bisevac
Ranch Hand
Posts: 48
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found example on http://www.roseindia.net/servlets/search.shtml and did some changes and now it is not working. Here is the code:




Search.java








what is doing command al.add(). Maybe this example is for searching and presenting just 1 record from database?
 
Bear Bibeault
Sheriff
Posts: 67752
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
Ugh! Java code in a JSP? In 2010?

I'd suggest using more up-to-date examples.
 
Ivan Bisevac
Ranch Hand
Posts: 48
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Ugh! Java code in a JSP? In 2010?


I am beginner in jsp and don't know why you say this.


Can you give me those examples or links to them. I just need search form and when search is complete to display results on second page. Then from second page to generate report. Can you give me those examples?
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read the article Mr.Bear gave to you?
It should give a clear idea what he is trying to tell you.
 
Bear Bibeault
Sheriff
Posts: 67752
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

Ivan Bisevac wrote:I am beginner in jsp and don't know why you say this.


As a beginner, it's important to not learn bad practices to begin with. Putting Java code in a JSP has been a discredited practice for over 8 years.

You want to avoid reference that use Java scriptlets. Modern JSP uses JSTL (JSP Standard Tag Library) and the EL (Expression Language).

You might also benefit from reading these articles: The Secret Life of JSPs and The Front Man (again).
 
Ivan Bisevac
Ranch Hand
Posts: 48
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, i will read this articles tomorow. Is there any book for this with examples?
 
Bear Bibeault
Sheriff
Posts: 67752
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
Any modern JSP book will cover JSTL and EL.
 
Ivan Bisevac
Ranch Hand
Posts: 48
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, i read book Core servlets and jsp pages and now am familiar with jsp. But now i have some questions.
After i get data from database do i put it in html table or there is a data grid in JSP? How to open one record in another page? For example i write sql query that gives me all employees with starting letter 'B' in name. I get some data and display it. How to make that customer make choice of just one employee and after employee is selected how to display result in another page? I don't need code just some advices. Thanks..
 
Bear Bibeault
Sheriff
Posts: 67752
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

Ivan Bisevac wrote:After i get data from database do i put it in html table or there is a data grid in JSP?

JSP is just a templating technology that helps you create the HTML pages. Any "data grid" will need to be rendered in HTML, JavaScript and CSS. There are 3rd party tag libraries that can help you do this (though I'm not personally impressed by any of them).

How to open one record in another page?

Based on what? A mouse click? If so, get the primary key from the clicked element and submit a request that goes through the whole process of fetching the data and displaying it.

The articles I referenced show this cycle.

 
Ivan Bisevac
Ranch Hand
Posts: 48
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Ivan Bisevac wrote:After i get data from database do i put it in html table or there is a data grid in JSP?

JSP is just a templating technology that helps you create the HTML pages. Any "data grid" will need to be rendered in HTML, JavaScript and CSS. There are 3rd party tag libraries that can help you do this (though I'm not personally impressed by any of them).

How to open one record in another page?

Based on what? A mouse click? If so, get the primary key from the clicked element and submit a request that goes through the whole process of fetching the data and displaying it.

The articles I referenced show this cycle.



Witch 3rd party library are those? Where i could find some info for that..
 
Bear Bibeault
Sheriff
Posts: 67752
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
I'd try google.
 
Ivan Bisevac
Ranch Hand
Posts: 48
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I'd try google.



I found some libraries but i asked for your experience. that's why i am here on forum.
 
Bear Bibeault
Sheriff
Posts: 67752
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
I've already said that I'm not impressed with any of them, so there isn't one I'd recommend.

I just do it myself. Creating an HTML table in JSP isn't at all hard, and I use jQuery on the client side to instrument the table with the appropriate behaviors.
 
I'm gonna teach you a lesson! Start by looking at this tiny ad:
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