⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login_jsp.java

📁 this is jsp project.By using this project we can chat using jsp code.
💻 JAVA
字号:
package org.apache.jsp.skin_005fmirc;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import jChatBox.Util.*;
import jChatBox.Chat.*;
import java.util.*;
import java.text.SimpleDateFormat;

public final class login_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.Vector _jspx_dependants;

  private org.apache.jasper.runtime.ResourceInjector _jspx_resourceInjector;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector = (org.apache.jasper.runtime.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("<html>\r\n");
      out.write("\r\n");
      jChatBox.Service.UserLogin UserLogin = null;
      synchronized (_jspx_page_context) {
        UserLogin = (jChatBox.Service.UserLogin) _jspx_page_context.getAttribute("UserLogin", PageContext.PAGE_SCOPE);
        if (UserLogin == null){
          try {
            UserLogin = (jChatBox.Service.UserLogin) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "jChatBox.Service.UserLogin");
          } catch (ClassNotFoundException exc) {
            throw new InstantiationException(exc.getMessage());
          } catch (Exception exc) {
            throw new ServletException("Cannot create bean of class " + "jChatBox.Service.UserLogin", exc);
          }
          _jspx_page_context.setAttribute("UserLogin", UserLogin, PageContext.PAGE_SCOPE);
        }
      }
      out.write('\r');
      out.write('\n');

	jChatBox.Chat.ChatroomManager ChatroomManager = jChatBox.Chat.ChatroomManager.getInstance();
	String chatroomTotalUsers = "", chatroomMaxUsers = "", chatroomName = "", chatroomSubject = "", chatroomDate = "";
	String chatroomID = request.getParameter("id");
	int ID = -1;
	if ( (chatroomID != null) && (!chatroomID.equals("")) )
	{
		try
		{
			ID = Integer.parseInt(chatroomID);
			Chatroom chatroom = ChatroomManager.getChatroom(ID);
			chatroomName = chatroom.getParams().getName();
			chatroomSubject = chatroom.getParams().getSubject();
			chatroomMaxUsers = ""+chatroom.getParams().getMaxUsers();
			chatroomTotalUsers = ""+chatroom.getTotalUsers();
			chatroomDate = (new SimpleDateFormat("yyyy/MM/dd HH:mm")).format(chatroom.getDate());
		} catch (Exception e)
		  {}
	}
	else
	{
		Vector vChat = ChatroomManager.getChatrooms();
		if (vChat.size() > 0)
		{
			Chatroom chatroom = (Chatroom) vChat.elementAt(0);
			ID = chatroom.getParams().getID();
			chatroomName = chatroom.getParams().getName();
			chatroomSubject = chatroom.getParams().getSubject();
			chatroomMaxUsers = ""+chatroom.getParams().getMaxUsers();
			chatroomTotalUsers = ""+chatroom.getTotalUsers();
			chatroomDate = (new SimpleDateFormat("yyyy/MM/dd HH:mm")).format(chatroom.getDate());
		}
	}
	String jspDisplay = UserLogin.doLogin(request, session);
	if (jspDisplay != null)
	{
		//response.sendRedirect(response.encodeRedirectURL(jspDisplay));
		
      if (true) {
        _jspx_page_context.forward( response.encodeURL(jspDisplay) );
        return;
      }

	}

      out.write("\r\n");
      out.write("<head>\r\n");
      out.write("<script language=\"Javascript\"><!--\r\n");
      out.write("function ready()\r\n");
      out.write("{\r\n");
      out.write("\tif(self.name == \"content\") self.parent.location.href=self.location;\r\n");
      out.write("\tdocument.chat.name.focus();\r\n");
      out.write("}\r\n");
      out.write("function enter()\r\n");
      out.write("{\r\n");
      out.write("\tdocument.chat.submit();\r\n");
      out.write("}\r\n");
      out.write("function info(id)\r\n");
      out.write("{\r\n");
      out.write("\tif (id.length > 0)\r\n");
      out.write("\t{\r\n");
      out.write("\r\n");
      out.write("\t\tlocation.href=\"");
      out.print( response.encodeURL("login.jsp?rand="+System.currentTimeMillis()) );
      out.write("&id=\"+id;\r\n");
      out.write("\t}\r\n");
      out.write("}\r\n");
      out.write("//--></script>\r\n");
      out.write("<title>Chat Login</title>\r\n");
      out.write("</head>\r\n");
      out.write("<body bgcolor=\"#FFFFFF\" leftmargin=\"1\" topmargin=\"1\" marginwidth=\"1\" marginheight=\"1\" onLoad=\"ready()\">\r\n");
      out.write("<form method=\"post\" action=\"");
      out.print( response.encodeURL("login.jsp") );
      out.write("\" name=\"chat\">\r\n");
      out.write("  <table width=\"98%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" align=\"center\">\r\n");
      out.write("    <tr>\r\n");
      out.write("      <td>\r\n");
      out.write("        <table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">\r\n");
      out.write("          <tr>\r\n");
      out.write("            <td colspan=\"2\" nowrap>\r\n");
      out.write("              <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
      out.write("                <tr>\r\n");
      out.write("                  <td nowrap><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"><b><font color=\"#000099\">NickName\r\n");
      out.write("                    :&nbsp;</font></b></font>\r\n");
      out.write("                    <input type=\"text\" name=\"name\" size=\"10\" maxlength=\"16\">\r\n");
      out.write("                    <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-2\" color=\"#FF0000\">&nbsp;&nbsp;<br>\r\n");
      out.write("                    ");

                    	if (UserLogin.getSysMessage()==Conf.CHATROOMNOTFOUND) out.print("CHATROOM NOT FOUND.");
                    	else if (UserLogin.getSysMessage()==Conf.CLOSED) out.print("CHATROOM IS CLOSED.");
                    	else if (UserLogin.getSysMessage()==Conf.NOVACANCIES) out.print("CHATROOM IS FULL.");
                    	else if (UserLogin.getSysMessage()==Conf.NAMENOTAVAILABLE) out.print("NAME NOT AVAILABLE.");
                    	else if (UserLogin.getSysMessage()==Conf.BANNED) out.print("YOU'RE BANNED.");
                    
      out.write("\r\n");
      out.write("                    </font> </td>\r\n");
      out.write("                </tr>\r\n");
      out.write("              </table>\r\n");
      out.write("\r\n");
      out.write("            </td>\r\n");
      out.write("          </tr>\r\n");
      out.write("          <tr>\r\n");
      out.write("            <td colspan=\"2\" nowrap><b><a href=\"javascript:enter()\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\">Enter</font></a></b>\r\n");
      out.write("              <b><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\">chatroom</font></b>\r\n");
      out.write("              <select name=\"chatrooms\" onChange=\"info(this.options[selectedIndex].value);\">\r\n");
      out.write("                <option value=\"none\">Select a chatroom</option>\r\n");
      out.write("                 ");

                     if (ChatroomManager != null)
                     {
                   	Vector chatrooms = ChatroomManager.getChatrooms();
                   	Chatroom chatroom = null;
                   	String selection = "";
                   	for (int i=0;i<chatrooms.size();i++)
                   	{
                   		chatroom = (Chatroom) chatrooms.elementAt(i);
                   		if (ID == chatroom.getParams().getID()) selection = " selected";
                   		else selection="";
                   		out.print("<option value=\""+chatroom.getParams().getID()+"\""+selection+">"+chatroom.getParams().getName()+"</option>");
                   	}
                     }
                 
      out.write("\r\n");
      out.write("              </select>\r\n");
      out.write("              </td>\r\n");
      out.write("          </tr>\r\n");
      out.write("        </table>\r\n");
      out.write("      </td>\r\n");
      out.write("      <td align=\"right\">\r\n");
      out.write("        <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
      out.write("          <tr bgcolor=\"#999999\">\r\n");
      out.write("            <td bgcolor=\"#0000AA\">\r\n");
      out.write("              <table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">\r\n");
      out.write("                <tr bgcolor=\"#FFFFFF\">\r\n");
      out.write("                  <td nowrap><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\">ChatRoom\r\n");
      out.write("                    : <font color=\"#FF0000\"><b>");
      out.print( chatroomName );
      out.write("</b></font> (");
      out.print( chatroomTotalUsers );
      out.write('/');
      out.print( chatroomMaxUsers );
      out.write(")<br>\r\n");
      out.write("                    Opened :<b> ");
      out.print( chatroomDate );
      out.write("<br>\r\n");
      out.write("                    </b><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Subject\r\n");
      out.write("                    :</font><b><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\">\r\n");
      out.write("                    <font color=\"#000066\"><b>");
      out.print( chatroomSubject );
      out.write("</b></font></font></b></font></td>\r\n");
      out.write("                </tr>\r\n");
      out.write("              </table>\r\n");
      out.write("            </td>\r\n");
      out.write("          </tr>\r\n");
      out.write("        </table>\r\n");
      out.write("      </td>\r\n");
      out.write("    </tr>\r\n");
      out.write("  </table>\r\n");
      out.write("</form>\r\n");
      out.write("<p>&nbsp;</p>\r\n");
      out.write("<table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\">\r\n");
      out.write("  <tr align=\"center\">\r\n");
      out.write("    <td valign=\"top\" width=\"40%\">\r\n");
      out.write("      <table width=\"60%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
      out.write("        <tr bgcolor=\"#999999\">\r\n");
      out.write("          <td bgcolor=\"#333399\">\r\n");
      out.write("            <table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">\r\n");
      out.write("              <tr bgcolor=\"#FFFFFF\">\r\n");
      out.write("                <td bgcolor=\"#FFFFFF\">\r\n");
      out.write("                  <p><font size=\"-1\" face=\"Verdana, Arial, Helvetica, sans-serif\"><b><font color=\"#FF0000\">jChatBox\r\n");
      out.write("                    2.6</font><font color=\"#666666\"><br>\r\n");
      out.write("                    </font></b>Look and feel : <b>mIRC</b> (English)<br>\r\n");
      out.write("                    <font size=\"-2\" color=\"#003399\">Chatrooms are performed\r\n");
      out.write("                    by jChatBox application. Server side is 100% JSP (Java Server\r\n");
      out.write("                    Pages). Client side could be HTML/CSS/JavaScript, Applet or Flash.<br>\r\n");
      out.write("                    System user can open and control many chatrooms. Moderators can manage\r\n");
      out.write("                    users (list, ban, kickoff), manage blacklist, generate transcripts\r\n");
      out.write("                    and apply chatrooms parameters as max users, filters ...<br>\r\n");
      out.write("                    Chatrooms are easily customizable. They can be extended by\r\n");
      out.write("                    designers or programmers through the jChatBox API. Have fun\r\n");
      out.write("                    ... </font><font size=\"-2\" color=\"#999999\"><br>\r\n");
      out.write("                    </font></font></p>\r\n");
      out.write("                  <table width=\"100%%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">\r\n");
      out.write("                    <tr>\r\n");
      out.write("                      <td><font size=\"-1\" face=\"Verdana, Arial, Helvetica, sans-serif\"><font size=\"-2\" color=\"#999999\"><a href=\"http://www.javazoom.net/jzservlets/jchatbox/jchatbox.html\" target=\"_blank\" style=\"text-decoration:none\">jChatBox\r\n");
      out.write("                        Homepage </a></font></font></td>\r\n");
      out.write("                      <td align=\"right\"><font size=\"-1\" face=\"Verdana, Arial, Helvetica, sans-serif\"><font size=\"-1\" face=\"Verdana, Arial, Helvetica, sans-serif\"><font size=\"-2\" color=\"#999999\"><a href=\"http://www.javazoom.net\" target=\"_blank\" style=\"text-decoration:none\">&copy;\r\n");
      out.write("                        JavaZOOM 1999-2004</a></font></font></font></td>\r\n");
      out.write("                    </tr>\r\n");
      out.write("                  </table>\r\n");
      out.write("                </td>\r\n");
      out.write("              </tr>\r\n");
      out.write("            </table>\r\n");
      out.write("          </td>\r\n");
      out.write("        </tr>\r\n");
      out.write("      </table>\r\n");
      out.write("    </td>\r\n");
      out.write("  </tr>\r\n");
      out.write("</table>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -