[JAVA] Import the instance and use it on another screen

I stumbled a little so I made a note

I think it's super basic, but it wasn't in PHP

Class instantiation.

It's easy to find because it's featured everywhere.

//Instantiation of customer information
Customer customer = new Customer();

You can instantiate it by doing a new like this.

But how can I use what was instantiated on screen A without new on screen B?

I was at a loss, but when I tried it, it was quite easy.

SetAttribute on screen A (Java)

request.setAttribute("customer", customer);

Import and receive on screen B (JSP)

<%@ page import="pizzaOrderForm.customer.*" %>
Customer customer = (Customer)request.getAttribute("customer");

Now you can use the instantiated customer on another screen.

Java road is difficult ...

Recommended Posts

Import the instance and use it on another screen
How to create a header or footer once and use it on another page
I want to use screen sharing on the login screen on Ubuntu 18
How to install and use Composer on an ECS instance on Ubuntu 16.04
Install the memcached plugin on MySQL and access it from Java
I opened the menu bar (option menu) on Android and saw it.
Item 59: Know and use the libraries
The image has been uploaded, but it doesn't appear on the screen! ??
Use the iostat command on CentOS 8
Steps to install Maven on Mac and use it in Eclipse
Creating an app and deploying it for the first time on heroku
Is it possible to put the library (aar) in the Android library (aar) and use it?
Recreate the container and then start it
Display an image on the base64 screen
How the website is displayed on the screen
How to pass the value to another screen
Java: Download the file and save it in the location selected in the dialog [Use HttpClient]
Resize or hide Button and EditText placed on the screen for each page
[Rails] When I use form_with, the screen freezes! ??
[Android] Get the tapped position (coordinates) on the screen
[Android] List all setting items on the setting screen
I installed Docker on EC2 and started it
Use your own docker-compose.yml on the command line
Compile and run Java on the command line
Solved the problem that profile and logout were not displayed on the screen after signup.
[AWS Lambda] Resize the image saved in S3 and save it in another S3 (using Ruby)
Install mecab-ipadic-neologd on Sakura VPS (ubuntu18.04) with low memory and use it from python