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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:52:05+00:00 2026-06-07T03:52:05+00:00

Got a homework assignment that is giving me problems…. Its modifying a JSF project

  • 0

Got a homework assignment that is giving me problems…. Its modifying a JSF project with two pages and a bean to fit MVC2 by adding two more pages and a controller servlet and another bean for the two additional pages. the new main page forwards to either the second new page or the old first page. My issue is response.getParameter() always results in null.

<%@page session="false" import="java.util.Iterator"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<jsp:useBean id="status" scope="request" class="JSFRegistration.Status" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>JSP Page</title>
    </head>
    <body>
        <% if (status!=null && !status.isSuccessful()){%>
            <font color="red">Processing errors:
                <ul><%Iterator errors=status.getExceptions();
            while (errors.hasNext()){
                Exception e = (Exception) errors.next();%>
                <li><%= e.getMessage()%><%}%></ul></font><%}%>
        <form action="LoginServlet" method="POST">
            <% String username = request.getParameter("username");
            if (username==null) username="";%>
            <input type="text" name="usernameTF" value="<%=username%>" />
            <% String password = request.getParameter("password");
            if (password==null) password="";%>
            <input type="password" name="passwordTF" value="<%=password%>" />
            <input type="submit" value="Login" />
        </form>

    </body>
</html>

this is basically a direct copy from our book but the fields I need for the new main page. Same for the controller servlet, a direct copy except only contains the fields I need.

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    RequestDispatcher view = null;
    Status status = new Status();
    request.setAttribute("status", status);
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    if (username==null || username.length()==0)
        status.addException(new Exception("Please enter username"));
    if (password==null)
        status.addException(new Exception("Please enter password"));
    if (!status.isSuccessful()){
        view = request.getRequestDispatcher("Login.jsp");
        //view.forward(request, response);
    }
    else
        try{
            request.setAttribute("username", username);
            request.setAttribute("password", password);
        view = request.getRequestDispatcher("Registration.jsp");
        } catch (Exception e) {
            status.addException(new Exception("Error"));
            view = request.getRequestDispatcher("Login.jsp");
        }
    view.forward(request, response);
}

and the Status class, again a direct copy from the book.

public class Status {
private ArrayList exceptions;

public Status(){
    exceptions = new ArrayList();
}
public void addException(Exception exception) {
    exceptions.add(exception);
}
public boolean isSuccessful(){
    return (exceptions.isEmpty());
}
public Iterator getExceptions(){
    return exceptions.iterator();
}

regardless of what is typed into the two boxes, stepping through a debug shows the values not getting passed to the parameters. I get the created exceptions printed above the screen for both fields if both have text, if only one has text and when both are empty.

  • 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-07T03:52:07+00:00Added an answer on June 7, 2026 at 3:52 am

    Your request parameter names do not match the input field names. You’ve assigned the input fields a name of usernameTF and passwordTF. They are then available by exactly those names as request parameter, but you’re attempting to get them using the names username and password. So you need either to fix the input field names, or the request parameter names so that they match each other.

    By the way, why falling back from a modern MVC framework like JSF to awkward 90’s style JSP with mingled business code? Is that really what the homework assignment is asking you? Also the HTML <font> element is deprecated since 1998. Where did you learn about it? Is the quality of the course really good?

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

Sidebar

Related Questions

I've got a homework assignment where I have a base class Package, and two
I got a homework assignment asking me to invoke a function without explicitly calling
I just got a homework assignment, and it's just creating a linear search algorithm
This is part of a homework assignment. I've got several questions asking find the
Homework. Dice Game. I've got an array that represents five rolls of a die.
hmm i got a homework, its 2 hours and i still have no clue
For my theory of computing languages class, we got a homework assignment to implement
I'm currently reviving an old homework assignment, where I'm writing a program that among
I've got a c homework problem that is doing my head in and will
This is my second week of learning python and I got an homework assignment

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.