Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need a jsp page for viewing,inserting and updating records in the same page  RSS feed

 
Britto Moris
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dear all,

I need to view, update and insert records through a jsp page.
example: Employee details..
If we give an admission number of an employee, and if the admission number exists in the database then the details like Name, DOB, DOR, Address, Contact info should be displayed in the appropriate fields.
(simply a select query in SQL) . The fields are editable and if we need to make any changes we can update in that details itself.
If admission number doesn't exists means we can insert all the details except the admission number and a temporary admission number is generated and displayed.
The problem with this is i can't able to revert it to the same page.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
149
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Britto Moris wrote:The problem with this is i can't able to revert it to the same page.

I'm not exactly sure what you mean by that. Please explain in greater detail.
 
Britto Moris
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need all these to happen in the same page itself..
(i.e. request and response are in same page)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
149
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's still not clear. You could either mean that the page submits to itself, or it could mean you don't want the page reloading at all. As this is 2014, I'll assume you mean the latter.

In which case, you'd use JavaScript and Ajax to make the backend requests.

Be sure not to put any Java code in a JSP -- that's outdated by over 12 years. Use controllers and proper web application structure.
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you probably have to define is a Web Service for CRUD operations against your employee data repository.

Making it REST based might make some sense - for instance you can load employee by url: /myApp/employee/Id123 would load the details for employee with an id of "Id123"

Once you have this web service up and running, invoking it via ajax from your JSP is fairly straightforward.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!