Hi,
This is my source code.
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class NewServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.write("Welcome");
NewJFrame o=new NewJFrame();
o.show();
// NewJFrame obj = new NewJFrame();
// out.write("JFrame name="+obj.getName());
// obj.setLocation(500, 500);
// obj.show();
// obj.setVisible(true);
class NewJFrame extends javax.swing.JFrame {
/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();
}
private void initComponents() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(150, 150, 150).addComponent(jButton1).addContainerGap(177, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(166, Short.MAX_VALUE).addComponent(jButton1).addGap(111, 111, 111)));
pack();
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}
out.write("******************Welcome");
} finally {
out.close();
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}
Please tell me what are the changes to be made in code to make jframe visible.
When i run this servlet from netbeans
IDE ,the jframe is pop uped.But i trying to run from
tomcat deployed folder ,jframe is not pop uped.I have seen log also,in that jframe object is created but it is not visible in browser.
Please tell me what are the changes to be made in code to make jframe visible.
When i run this servlet from netbeans IDE ,the jframe is pop uped.But i trying to run from tomcat deployed folder ,jframe is not pop uped.I have seen log also,in that jframe object is created but it is not visible in browser.