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 6112423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:44:36+00:00 2026-05-23T14:44:36+00:00

import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class LoginServlet extends HttpServlet {

  • 0
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginServlet extends HttpServlet
{
private void sendLoginPage (HttpServletResponse res, HttpServletRequest req, boolean error)
throws ServletException,IOException
{
    res.setContentType("text/html");
    PrintWriter o = res.getWriter();        
    o.println("<html><head><title>Sample Login Page</title></head><body>Welcome to Login Page : ");
    if (error)
    o.println("<fieldset><legend>Login Form : </legend>");
    o.println("Login Failed, Please Try Again");
    o.println("<form method="+"post"+">");
    o.println("<br/><input type="+"text"+"value="+"username"+"/>");
    o.println("<br/><input type="+"password"+"value="+""+"/>");
    o.println("<br/><input type="+"button"+"value="+"Submit"+"/>");
    o.println("</form></fieldset></body></html>");
}

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

public void doPost (HttpServletResponse res, HttpServletRequest req)
throws ServletException,IOException
{
    String username = req.getParameter("username");
    String password = req.getParameter("password");
    if ( username.equals("*******") && password.equals("*******") )
    {
        res.sendRedirect ("http://localhost:7001/ten/r1");
    }
    else 
    {
        sendLoginPage ( res, null, true ) ;
    }
}           
}                   

Well this Servlet compiles okay without any errors and also gets deployed on the server
but shows this error when trying to access it through url :

HTTP method GET is not supported by this URL

  • 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-23T14:44:37+00:00Added an answer on May 23, 2026 at 2:44 pm

    You have the HttpServletResponse and HttpServletRequest parameters reversed on your methods.

    Side note: Using the @Override annotation on overridden methods would cause a compile error for this (assuming you’re using at least Java 1.5)

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

Sidebar

Related Questions

import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.util.Date; public class HelloServlet extends HttpServlet {
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class Filereader { public static void main(String[]
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class DateDemo { public static void main(String[]
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
I have a simple code below: import java.util.ArrayList; public class BoidList extends ArrayList {
i have the following action class: package com.pendulum.web; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest;
I'm confused by the following code: import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class
Given the following program: import java.io.*; import java.util.*; public class GCTest { public static
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import javax.mail.event.*; import java.net.*;
I'm trying to work with the below code: import javax.servlet.*; import javax.servlet.http.*; import java.io.*;

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.