Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8698265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:41:36+00:00 2026-06-13T01:41:36+00:00

Well currently i’m doing a simple application using jsp, servlet, jstl with hibernate integration,

  • 0

Well currently i’m doing a simple application using jsp, servlet, jstl with hibernate integration, I have a problem regarding my servlet method since doPost and doGet require action(clicking the link/submit button) to happen. My question is how can I fetch the database records onload without doing any action on my servlet. What I want to do is once the admin(user) click the userlist.jsp page the combobox will be populated by the records coming from the database, onload.

So far this is what I’ve got:
my Register.jsp page

I already implement and call jstl so I can easily loop through the wole list(records) from the database.

<select name="role" >
<c:forEach var="load" items="${load}">
    <option><c:out value="${load}"></c:out></option>
</c:forEach>
</select>

and my servlet:

protected void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
loadRole(request, response);
}

This is my method loadRole I just call the method just to separate the logic from the request and response object.

private void loadRole(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
    HttpSession roleSession = request.getSession();
    Session session = factory.openSession();
    session.beginTransaction();

        Query query = session.createQuery("SELECT cd FROM Role");
        List load = query.list();
        roleSession.setAttribute("load", load);

        request.getRequestDispatcher("Forms/Register.jsp").forward(request, response);

    session.getTransaction().commit();
    session.close();

}

This piece of code is working however it need to do first doPost/doGet method before fetching the database records.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:41:37+00:00Added an answer on June 13, 2026 at 1:41 am

    You can use init() method for initialization. Reference here.

    Next

    how can I pass the result to session using init method?

    Use service() method. You can retrieve HttpRequest and HttpResponse.

    You have to reference Servlet Life Cycle. Here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, the question kinda nails it down. I'm currently doing something like this: using
I'm currently using an application in python which works quite well but when I'm
I am currently doing reasonably well in functional programming using F#. I tend, however,
I currently have a web based private chat application that is going very well.
Currently I have a zoom implemented for my drawing application which works quite well.
I have an application that currently does not support Nexus 7 very well. So
Well guys; Here's my problem: I currently have a class extending another that will
Well currently I have this: <rich:fileUpload addLabel=Agregar clearAllLabel=Quitar todos clearLabel=Quitar deleteLabel=Quitar doneLabel=Completado uploadLabel=Subir archivos
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
I'm currently doing the following to compensate for boolean's not mapping well to radio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.