The Java Servlet change did not trigger an update in the web content

While using Eclipse to develop a website where Servlet sends data to JSP, I encountered an issue. Despite modifying the data in the Servlet, it continued to send outdated information to the JSP page. I attempted the following options:

Menu - Project - clean (Click this option if Build Automatically is not used)

Menu - Project - Project Build Automatically (Check this option)

I also tried restarting and cleaning the Tomcat server.

Here is an example:

Product.java

            public class Product {
            private String id;
            private String name;
            private long price;
            public String getId() {
                return id;
            }
            public void setId(String id) {
                this.id = id;
            }
            public String getName() {
                return name;
            }
            public void setName(String name) {
                this.name = name;
            }
            public long getPrice() {
                return price;
            }
            public void setPrice(long price) {
                this.price = price;
            }
            public Product(String id, String name, long price) {
                super();
                this.id = id;
                this.name = name;
                this.price = price;
            }
        }

ProductModel.java

        public class ProductModel {
        public Product find() {
            return new Product("www","aaa",1000);  
        }
        public List<Product> findAll()
        {List<Product> result= new ArrayList<Product>();
        result.add(new Product("xxx","yyy",100));
        result.add(new Product("p04","name 2",200));
        result.add(new Product("p037","name 3",300));
        return result;
            }
        }}

ProductController.java

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

                    /**
                     * @see HttpServlet#HttpServlet()
                     */
                    public ProductController() {
                        super();
                        // TODO Auto-generated constructor stub
                    }

                    /**
                     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
                     */
                    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                        // TODO Auto-generated method stub
                        PrintWriter out= response.getWriter();
                        Gson gson= new Gson();
                        ProductModel productModel= new ProductModel();
                        String action = request.getParameter("action");
                        if(action.equalsIgnoreCase("demo1"))
                        {
                            out.print(gson.toJson(productModel.find()));
                            out.flush();
                            out.close();
                        }
                        else if (action.equalsIgnoreCase("demo2"))
                        {
                            out.print(gson.toJson(productModel.findAll()));
                            out.flush();
                            out.close();
                        }
                    }

                    /**
                     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
                     */
                    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                        // TODO Auto-generated method stub
                        doGet(request, response);
                    }

                }

index.jsp

           
<!-- JavaScript and HTML code -->

When I made changes inside ProductModel.java as shown above, the results were still incorrect. Please assist me in resolving this issue. Thank you.

Answer №1

Big thanks to @rhenesys for the helpful tip! Just wanted to spread the word in case anyone else is experiencing the same problem. Switching to a different browser did the trick for me, I went with Chrome and it solved everything.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Create a stylish navigation dropdown with MaterializeCSS

Incorporating the materializecss dropdown menu feature, I encountered an issue where only two out of four dropdown menu items were visible. Here is the HTML code snippet in question: <nav class="white blue-text"> <div class="navbar-wrapper con ...

Is the form being submitted with the href attribute?

Does this code ensure security? <form id="form-id"> <input type='text' name='name'> <input type='submit' value='Go' name='Go'/></form> <a href="#" onclick="docume ...

What is the best way to incorporate multiple input boxes into a single alertbox for repeated use?

I attempted to use the same alertbox for 3 different input elements by converting it into a class and using getElementsByClassName, but unfortunately, it did not work as expected. Here is what I tried: <input type="text" class="form-control date notif" ...

The random number generator in TypeScript not functioning as expected

I have a simple question that I can't seem to find the answer to because I struggle with math. I have a formula for generating a random number. numRandomed: any; constructor(public navCtrl: NavController, public navParams: NavParams) { } p ...

Import .vue single file component into PHP application

I've been struggling to integrate a .vue single file component into my php app without using the inline template method. Since I don't have a node main.js file to import Vue and require the components, I'm not sure how to properly register m ...

Check if the data-indices of several div elements are in sequential order using a jQuery function

Is there a way to implement a function in jQuery-ui that checks the order of div elements with data-index when a submit button is pressed? I have set up a sortable feature using jQuery-ui, allowing users to rearrange the order of the divs. Here is an exam ...

PHP AJAX Bootstrap validation: A dynamic approach to form validation

I am in need of serializing my form so that it can be transmitted to a php file through Ajax. I have integrated Bootstrap for form validation, but despite this, the php code is returning an empty array. Interestingly, the debugger displays that postData co ...

Storing the radio button's selected value in local storage using Vue JS

I have a pair of radio buttons that are linked together to accept a boolean value, either true or false. I am trying to implement a functionality where the selected value is stored in local storage. For example, if true is chosen, then true will be saved i ...

error: "undefined property cannot be read"

I am encountering an issue on our site where a bot is needed to work properly. The error message I am receiving is "cannot read property ´value´ of undefined". I have already set the bind_address to 0.0.0.0, but that did not resolve the issue (I also tri ...

Ways to retrieve a designated object linked to a specific value within a JavaScript structure

I am facing a challenge where I need to set a javascript property object with values from another property object within the same instance. Currently, I have the following object: var PLAYER = { slides: { { slide_id: 60, slide_content: 'c ...

Using npm webpack-mix to execute a JavaScript function stored in a separate file

Currently, I am facing a challenge with accessing a function that is defined in the table.js file from within my index.html. Here is a snippet of the code: table.js let table; function set_table(table) { this.table = table; consol ...

Considerations for AJAX when dealing with MVC FormsAuthentication timeouts

Seeking assistance. In my customized ASP.net MVC3 app, all controllers extend from a controller I've created. When FormsAuthentication times out, users are correctly redirected to the login page when attempting to access any page (standard procedure) ...

The Web-application encounters a challenging error of 403() Permission denied

Currently, I'm facing a puzzling situation with my accounting software, Kivitendo. It is hosted on a PLESK Debian12 Server. Strangely, whenever I attempt to select a chart using the magnifying glass icon (please refer to the accompanying image), an un ...

What is the best method for automatically closing the modal window?

I implemented a modal window on my website. Within the modal, there is a green button labeled "Visit" which triggers the "Bootstrap Tour". I aim for the modal to automatically close when the tour starts. To access this feature on my site, users need to ...

Sending inputs by executing a Python script to a Java archive file

Recently, I've been working on a simplistic Java application that performs addition by passing two arguments during runtime. Here is the code snippet: package test_python; import java.util.concurrent.TimeUnit; public class Test_python { public ...

Function "Contains" not Present in Object

Upon executing the code provided below, I encounter the following error message. An issue has arisen: Cannot find function contains in object Is Patient Fasting?/# of Hours->Yes; 12 hours. Here is the snippet of my code: var i = 0; var tempF ...

Creating a Map Using HTML and JavaScript

My current project involves creating a simple map that can be moved with mouse drag functionality, featuring images such as islands. I have successfully retrieved the mouse position by declaring variables posX and e.clientX, as well as for e.clientY. Howe ...

Need a tool for validating forms?

I am currently facing some confusion with the UI Validation plugin that we are using. Within our application, we employ Spring MVC, Jquery & Bootstrap. As we delve into UI development, we have encountered uncertainty in selecting an appropriate Validation ...

I'm having trouble displaying the result of my calculation in the code. Could it be because I forgot to include an output tag?

I am attempting to develop a Miles Per Gallon (MPG) calculator using Javascript. However, I'm encountering difficulties with displaying the results once the "Calculate" button is pressed. <html> <head> <title> MPG Calculator </ti ...

Creating a JQuery function that saves an image uploaded from a file uploader when a specific button is clicked within a dynamically generated div

After making an Ajax call, I created a new <div> (referred to as the new div) and appended it to an existing <div> (known as the old div). Within the new div, I included an input [type=file] and a button. My goal is to save the image upon clic ...