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

📄 login_jsp.java

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

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 {

 XMLPropertyResourceBundle chatroomBundle = new XMLPropertyResourceBundle(); 
  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("\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){
          UserLogin = new jChatBox.Service.UserLogin();
          _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 = "";
	/* I18N support since Servlets 2.3. */
	//try
	//{
	//  request.setCharacterEncoding(chatroomBundle.getString("global.encoding"));
	//} catch (Exception e) {}
	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();
			chatroomBundle = (XMLPropertyResourceBundle) XMLConfig.RESOURCES.get(chatroom.getParams().getLanguage());
			chatroomSubject = chatroom.getParams().getSubject();
			chatroomMaxUsers = ""+chatroom.getParams().getMaxUsers();
			chatroomTotalUsers = ""+chatroom.getTotalUsers();
			chatroomDate = (new SimpleDateFormat(chatroomBundle.getString("login.date.format"))).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();
			chatroomBundle = (XMLPropertyResourceBundle) XMLConfig.RESOURCES.get(chatroom.getParams().getLanguage());
			chatroomSubject = chatroom.getParams().getSubject();
			chatroomMaxUsers = ""+chatroom.getParams().getMaxUsers();
			chatroomTotalUsers = ""+chatroom.getTotalUsers();
			chatroomDate = (new SimpleDateFormat(chatroomBundle.getString("login.date.format"))).format(chatroom.getDate());
		}
                else
                {
                   chatroomBundle = (XMLPropertyResourceBundle) XMLConfig.RESOURCES.get(XMLConfig.DEFAULTLANGUAGE);
                }
	}
	response.setContentType("text/html; charset="+chatroomBundle.getString("global.encoding"));
	String jspDisplay = UserLogin.doLogin(request, session);
	if (jspDisplay != null)
	{
		//response.sendRedirect(response.encodeRedirectURL(jspDisplay));
		
      if (true) {
        _jspx_page_context.forward( jspDisplay );
        return;
      }

	}

      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\" />\r\n");
      out.write("<script language=\"JavaScript\" type=\"text/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) && (id > -1))\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>");
      out.print( chatroomBundle.getString("login.title") );
      out.write("</title>\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
      out.print( chatroomBundle.getString("global.encoding") );
      out.write("\" />\r\n");
      out.write("</head>\r\n");
      out.write("<body onload=\"ready()\">\r\n");
      out.write("<form action=\"");
      out.print( response.encodeURL("login.jsp") );
      out.write("\" method=\"post\" name=\"chat\" id=\"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 valign=\"top\">\r\n");
      out.write("        <table width=\"100%\">\r\n");
      out.write("          <tr>\r\n");
      out.write("            <td colspan=\"2\" nowrap=\"nowrap\">\r\n");
      out.write("              <table width=\"100%\">\r\n");
      out.write("                <tr>\r\n");
      out.write("                  <td class=\"b\" nowrap=\"nowrap\">");
      out.print( chatroomBundle.getString("login.username.label") );
      out.write("\r\n");
      out.write("                    <input type=\"text\" name=\"name\" size=\"10\" maxlength=\"16\" />\r\n");
      out.write("                  </td>\r\n");
      out.write("                </tr>\r\n");
      out.write("                    ");

                    	if (UserLogin.getSysMessage()==Conf.CHATROOMNOTFOUND) out.print("<tr><td class=\"s\">"+chatroomBundle.getString("login.chatroomnotfound.error")+"</td></tr>");
                    	else if (UserLogin.getSysMessage()==Conf.CLOSED) out.print("<tr><td class=\"s\">"+chatroomBundle.getString("login.closed.error")+"</td></tr>");
                    	else if (UserLogin.getSysMessage()==Conf.NOVACANCIES) out.print("<tr><td class=\"s\">"+chatroomBundle.getString("login.novacancies.error")+"</td></tr>");
                    	else if (UserLogin.getSysMessage()==Conf.NAMENOTAVAILABLE) out.print("<tr><td class=\"s\">"+chatroomBundle.getString("login.namenotavailable.error")+"</td></tr>");
                    	else if (UserLogin.getSysMessage()==Conf.BANNED) out.print("<tr><td class=\"s\">"+chatroomBundle.getString("login.banned.error")+"</td></tr>");
                    
      out.write("\r\n");
      out.write("              </table>\r\n");
      out.write("            </td>\r\n");
      out.write("          </tr>\r\n");
      out.write("          <tr>\r\n");
      out.write("            <td class=\"b\" colspan=\"2\" nowrap=\"nowrap\"><a href=\"javascript:enter()\">");
      out.print( chatroomBundle.getString("login.join.link") );
      out.write("</a>");
      out.print( chatroomBundle.getString("login.join.label") );
      out.write("\r\n");
      out.write("              <select name=\"chatrooms\" onchange=\"info(this.options[selectedIndex].value);\" class=\"dropdown\">\r\n");
      out.write("                <option value=\"-1\">");
      out.print( chatroomBundle.getString("login.list.label") );
      out.write("</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=\"selected\"";
                   		else selection="";
                   		out.println("<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 class=\"borderin\" border=\"0\">\r\n");
      out.write("          <tr>\r\n");
      out.write("            <td>\r\n");
      out.write("              <table width=\"100%\">\r\n");
      out.write("                <tr>\r\n");
      out.write("                  <td class=\"sbb\" nowrap=\"nowrap\">");
      out.print( chatroomBundle.getString("login.chatroom.label") );
      out.print( chatroomName );
      out.write("</td>\r\n");
      out.write("\t\t\t\t</tr>\r\n");
      out.write("\t\t\t\t<tr>\r\n");
      out.write("                  <td class=\"sbb\" nowrap=\"nowrap\">");
      out.print( chatroomBundle.getString("login.subject.label") );
      out.print( chatroomSubject );
      out.write("</td>\r\n");
      out.write("                </tr>\r\n");
      out.write("\t\t\t\t<tr>\r\n");
      out.write("\t\t\t\t  <td class=\"xsg\" nowrap=\"nowrap\">");
      out.print( chatroomBundle.getString("login.open.label") );
      out.print( chatroomDate );
      out.write("</td>\r\n");
      out.write("\t\t\t\t</tr>\r\n");
      out.write("\t\t\t\t<tr>\r\n");
      out.write("                  <td class=\"xsr\" nowrap=\"nowrap\">");
      out.print( chatroomBundle.getString("login.useramount.label") );
      out.print( chatroomTotalUsers );
      out.write("</td>\r\n");
      out.write("                </tr>\r\n");
      out.write("\t\t\t\t<tr>\r\n");
      out.write("                  <td class=\"xsr\" nowrap=\"nowrap\">");
      out.print( chatroomBundle.getString("login.userlimit.label") );
      out.print( chatroomMaxUsers );
      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("</form>\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 + -