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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:33:16+00:00 2026-06-19T02:33:16+00:00

I created a simple servlet which was printing some message like this: @WebServlet(/servletExample) public

  • 0

I created a simple servlet which was printing some message like this:

@WebServlet("/servletExample")
public class ServletExample extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 

        PrintWriter out = response.getWriter();
        out.println("Hello there");

    }

Everything worked well.
Then i created 2 jsp pages like this:

<body>
    <form method="post" action="servletExample">
        <table border="0">
            <tr>
                <td>
                    First name:
                </td>
                <td>
                    <input type="text" name="firstname"/>
                </td>               
            </tr>
            <tr>
                <td>
                    Last name:
                </td>
                <td>
                    <input type="text" name="lastname"/>
                </td>               
            </tr>   
            <tr>
                <td colspan="2">
                    <input type="submit" value="Submit"/>
                </td>               
            </tr>
        </table>
    </form>
</body>

and

<body>
    <%
        String firstName = (String)request.getAttribute("firstname");
        String lastName = (String)request.getAttribute("lastname");

        out.println(firstName+ " "+lastName);
    %>
</body>

The servlet looks like this now:

@WebServlet("/servletExample")
public class ServletExample extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 

        String firstName=request.getParameter("firstname");
        String lastName=request.getParameter("lastname");

        if(firstName == null || lastName==null){
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
            return;
        }

        request.setAttribute("firstname", firstName);
        request.setAttribute("lastname", lastName);
        getServletContext().getRequestDispatcher("/output.jsp").forward(request, response);
    }
}

When i run it i see that form but when i submit i see “Hello there” from the example i did 2 days ago. Whatever i do i see that.
What do i have to clean?
What am i missing?

Edit: I use eclipse and tomcat 7

  • 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-19T02:33:18+00:00Added an answer on June 19, 2026 at 2:33 am

    Assuming you are in Eclipse, stop your Tomcat server, select your project, in Eclipse’s menu select Project and Clean and then Build Project. Then restart your Tomcat server and try again.

    Eclipse uses the last built project version with Tomcat every time you run. You need to clean up the project and rebuild it for Eclipse and Tomcat to refresh the changes.

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

Sidebar

Related Questions

Very simple question about jstl. Consider Map which return by Controller/Servlet. I would like
Hello I`ve created simple WFC DataService and connected entit model with my database. This
Could someone help me on this, I have created simple web services using axis2
I am new to Repository concept and get some questions. I have created simple
I created a simple tooltip for some buttons in an admin panel I am
I created a simple asm hello world x86 bootloader, I'd like to embed it
I ve created a sample REST web service which writes some data in a
I am building a servlet which responses with a json message.The problem is that
I have a class which acts as a simple crawler and I want to
I have created a simple web application, for which I want all responses with

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.