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

  • SEARCH
  • Home
  • 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 7636411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:40:22+00:00 2026-05-31T07:40:22+00:00

i am having trouble getting the page to work, what i am doing is

  • 0

i am having trouble getting the page to work, what i am doing is when i click the link it should connect to the database and display the data to the browser.

this is my jsp code:

        <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

       </head>
       <body>
       <%  
          String str = (String)request.getAttribute("acId");
        %>
        Account ID: <a href="detailsservlet"> <%= str %>
       </body>
       </html>

this is my servlet code:

       package com.Project.Hdfc;

       import java.io.IOException;
       import java.io.PrintWriter;
       import java.sql.Connection;   
       import java.sql.DriverManager;
       import java.sql.ResultSet;
       import java.sql.Statement;

       import javax.servlet.ServletException;
       import javax.servlet.http.HttpServlet;   
       import javax.servlet.http.HttpServletRequest;
       import javax.servlet.http.HttpServletResponse;


       public class detailsservlet extends HttpServlet {
@Override 
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {



    res.setContentType("text/html");
    PrintWriter pw = res.getWriter();
    Connection con;
    Statement stmt;
    ResultSet rs;
    try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        con = DriverManager.getConnection("jdbc:odbc:DSN","scott","krishna");
        stmt = con.createStatement();
        rs = stmt.executeQuery("Select * from custm");
        pw.println("Id "+ " Name" +" Address" + "<br>");
        while(rs.next())
        {
        pw.println(rs.getInt(1)+" "+rs.getString(2) + " " + rs.getString(3) + "<br>");
        }
        }
        catch (Exception e){
        pw.println(e);
        }
        }

}
  • 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-05-31T07:40:23+00:00Added an answer on May 31, 2026 at 7:40 am

    You have a doPost method but not doGet method in your sevlet code. If you only want to get information from the jsp page, but not to post any data to the database, then only use doGet. If you want to both post and get, a kind of solution is to

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws  ServletException, IOException {
        doPost(req, res);
    }
    

    or the other way around, as thats nicer.

    Also you shouldnt mix html tags in your Java code.

    Another solution to your code is to change your a href=”detailssevlet” to a input type button inside a element, as that will provide a POST to the sever, and not a GET, if thats what you want to do, but not in this case, since you fetch data, not submit it to the server.

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

Sidebar

Related Questions

I'm having trouble getting this to work...it just replaces the entire page with the
I am having trouble getting an core-data backed NSArrayController to work properly in my
I am having trouble getting the page to work. I have my form method
i am having trouble getting this to work, can any one spot the issue?
I'm sure this is fairly straightforward but i'm having trouble getting it to work.
I'm having trouble getting scrollTop to work on a search page I'm working on.
i am having trouble getting this XMLHttpRequest to work properly, this is my first
Having some trouble getting this to work... I basically want the report to look
I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the
I'm working on a Wordpress site and am having trouble getting this page to

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.