NPE NPE - 6 months ago 68
Java Question

JOptionPane.showMessageDialog on Java Platform Enterprise Edition (JSP)

I just wanted to know can we use

in Java Server Page(*.JSP) like

I have tried this code

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="javax.swing.JOptionPane"%>

JOptionPane.showMessageDialog(null, "Message");

and I got this :

HTTP Status 500 - Internal Server Error


This is not possible as calling JOptionPane.showMessageDialog requires the following params

public static void showMessageDialog(Component parentComponent,
                 Object message)
                          throws HeadlessException

Brings up an information-message dialog titled "Message".

    parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
    message - the Object to display

The parent component here should be valid subclass of Component class or in layman terms some kind of swing or awt frame.Which JSP won't be able to provide.