• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

servlet and mysql

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello , im currently trying to finish an assignment and im totally at my witts end lol. the servlet is a note taking servlet that connects to a database (using mvc). so far my application , connects to the database and saves the data to the scope. and ive displayed the titles of the notes on my jsp in a table. now imworking on the part of my application that displays the notes. you click on the titles of thenotes and it leads you to notes details page that displays the actual note. but these instructions have me confused


If the User is logged in, your controller should expect a noteId parameter. For example:
EditNote?noteId=12345
If the noteId parameter is not present, or if it is not an integer, simply redirect the User back to the MyNotes page.
If the noteId parameter value is valid, your controller is to query your database and retrieve the details of the note with the corresponding ID.

If your controller successfully retrieves the note data, it should:
- Package the note into a model and add the model to the request object.
- Forward both request and response objects to the EditNote View.

im not sure how to do this , or even start it and its left me really confused on how to continue.


this is my notedetails controller



this is the MyNotes controller, which is the begining of my project, that i got to work. and i figured this would probably work for the note display part , so its the same thing.

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are already checking for whether the User is logged in, so that covers part 1 (if the User is logged in).

Your NoteDetails should be expecting a parameter (noteId).
So that's part 2. Get that parameter from the request. If it doesn't exist (or is not an int) then redirect to MyNotes.
Part 3 is actually getting the Note that's been requested.

Get part 2 sorted and you can move onto part 3.
 
John ortega
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:You are already checking for whether the User is logged in, so that covers part 1 (if the User is logged in).

Your NoteDetails should be expecting a parameter (noteId).
So that's part 2. Get that parameter from the request. If it doesn't exist (or is not an int) then redirect to MyNotes.
Part 3 is actually getting the Note that's been requested.

Get part 2 sorted and you can move onto part 3.



alright heres what ive done . i used a hidden form field in my jsp , were i have the tabe of link. saved the id to noteid. now im trying to get that formfield noteid , in my notesdetails controller so i can use it for my query and finally be done lol . but i cant get the noteid that i saved in the hidden form. i tried int id = Integer.parseInt(request.getParameter("noteid")); but it comes up as null. how can i access the hidden for field data?

this is my jsp that has the table of links of titles, unless ive misused the hidden form field to save the note id. it should be right


here the controller for my notedetails.im trying to get the noteid i saved from the hidden form field in my jsp
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've now removed step 1 (checking if the user is logged in).
I'd put that back in.

I don't see a form in your html.
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic