简体   繁体   中英

What is the equivalent of JOptionPane in JSP?

I want to make such as JOptinonPane in JSP. What is the equivalent of it JSP?

First of all, JSP runs at the webserver, produces HTML/CSS/JavaScript and sends it to webbrowser. Webbrowser retrieves HTML/CSS/JavaScript and interprets/applies/executes it. If Java/JSP has done its task right, the webbrowser should not retrieve any line of Java/JSP code. Simply because it doesn't understand it. Rightclick page and choose View Source . It'll become clear. Does it? :)

Now, in a webbrowser you can use JavaScript to show dialogs. Eg an alert dialog with one button:

<script>alert('An alert message');</script>

A confirmation dialog with two buttons (which returns true or false depending on button pressed):

<script>var confirm = confirm('Are you sure?');</script>

A prompt dialog message with two buttons (which returns the input or nothing depending on button pressed):

<script>var input = prompt('Enter input', '');</script>

Just write it down in the JSP page the usual way. JSP will send it to the webbrowser.

See also:


To get a step further, you can make use of more advanced JavaScript and a good shot of CSS in combination with a HTML <div> element to create a nice-looking dialog. You can find here some examples based on jQuery UI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM