Tag:JSP

  • JSP DWR cascade effect code

    Time:2021-9-17

    dwr.jsp <script src=”dwr/interface/JUserChec.js”></script> <script src=”dwr/engine.js”></script> <script src=”dwr/util.js”></script> <script type=”text/javascript”> function changeQx(p) { var val = p.value; //alert(val); JUserChec.jiLian(val, haschange); } function haschange(changeVal) { //alert(changeVal); var jd = document.getElementById(“jd”); var op = new Option(changeVal, changeVal); jd.options.length=0; jd.options.add(op); } </script> <body> <br><br> <select onchange=”changeQx(this)”> <option value=”a”>a</option> <option value=”b”>b</option> <option value=”c”>c</option> </select> <select> </select> </body> dwr.xml <?xml version=”1.0″ […]

  • Pure jsp creates infinite levels of tree code

    Time:2021-9-15

    It’s not complicated to build a tree, but we usually do two or three layers. Such data usually comes from multiple tables, such as departments and employeesHowever, this self connected table, which has no definite hierarchy, may be infinite multi-levelFor example, a is the superior of B, B is the superior of C, and C […]

  • JSP connection method to MySQL / MS SQL Server / Oracle database [sorting]

    Time:2021-9-14

    Method of connecting JSP to MySQL databaseFirst, copy the MySQL database connection driver to the Tomcat / common / lib packageDownload mysql-connector-java-5.1.6.ziphttp://mysql.cs.pu.edu.tw/Downloads/Connector-J/mysql-connector-java-5.1.6.zip Configure Tomcat’s virtual directory – omittedCreate a JDBC mysql.jsp pageThe page code is as follows: Copy codeThe code is as follows: <%@ page contentType=”text/html;charset=gb2312″%> <%@ page import=”java.sql.*”%> <% final String MYSQLDBDRIVER=”org.gjt.mm.mysql.Driver”; final String […]

  • JSP method for generating page verification code [with code]

    Time:2021-9-13

    Image. JSP —————————————- JSP page for generating random verification code imageThe code is as follows:   Copy codeThe code is as follows: <%@ page contentType=”image/jpeg” import=”java.awt.*, java.awt.image.*,java.util.*,javax.imageio.*” %> <%! Color getRandColor(int fc,int bc) { Random random = new Random(); if(fc>255) fc=255; if(bc>255) bc=255; int r=fc+random.nextInt(bc-fc); int g=fc+random.nextInt(bc-fc); int b=fc+random.nextInt(bc-fc); return new Color(r,g,b); } %> <% […]

  • A general JSP paging pagebean

    Time:2021-9-11

    package com.shaccp.web.util; import java.util.List; public class PageBean { /** * * * @author ppy 2008-10-18 14:3:56 *Totalrecords total records*List saves the paged data*Pageno current page*PageSize page size*Query saves the string of the user query*Pageaction is a servlet or action (struts) that operates paging*Method (method corresponding to action in struts)* * */ private int totalRecords; private […]

  • The process of permanent domain name change of JSP website

    Time:2021-9-10

    1. Make a virtual host for the old domain name under TomcatThe first page is index.jsp, and the 404 error page is unfind.jspThe home page uses 301 steering, which is conducive to search engine optimization<% response.setStatus(301); response.setHeader( “Location”,”http://***.com”); response.setHeader( “Connection”, “close”); %> Unfind.jsp determines the address of the new page that the old page should […]

  • Three methods to solve the problem of web program displaying Chinese in JSP development

    Time:2021-9-8

    Method 1: the simplest and most used method   <%@ page language=”java” pageEncoding=”GBK” %> Or <% @ page contenttype = “text / HTML”; charset=gbk”;> GB2312 or GBK can be used here, but GBK supports more characters than GB2312.This method is used for Chinese display in JSP pages.Method 2: use filter The filter is mainly used for […]

  • Principle of JSP hibernate data saving operation

    Time:2021-9-7

    Data saving, updating and deletion:1. Session. Save() method:The session. Save () method is used for the persistent saving of entity objects, that is, when the session. Save () method is executed, the corresponding insert SQL statement will be generated to save the data. As shown in the following code:User user=new User(); user.setName(“zx”); Transaction tx=session.beginTransaction(); session.save(user); […]

  • Introduction to JSP hibernate function

    Time:2021-9-6

    1、Configuration/SessionFactory/Session The configuration instance represents a complete set of Java type to SQL database mappings in an application. Configuration is used to build a (immutable) sessionfactorySessionfactory is thread safe and expensive to create.Session is non thread safe and lightweight. A session corresponds to a JDBC connection,The connection () of the session will get the database […]

  • JSP hibernate Getting Started tutorial page 1 of 3

    Time:2021-9-4

    For example: Copy codeThe code is as follows: HibernateTest.java import onlyfun.caterpillar.*; import net.sf.hibernate.*; import net.sf.hibernate.cfg.*; import java.util.*; public class HibernateTest { public static void main(String[] args) throws HibernateException { SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Session session = sessionFactory.openSession(); List users = session.find(“from User”); User updated = null; for (ListIterator iterator = users.listIterator(); iterator.hasNext(); ) { […]

  • JSP check box usage

    Time:2021-9-1

    1. On the page Copy codeThe code is as follows: <td width=”4%” height=”26″ align=”center”> <input type=”checkbox” name=”checkbox” value=<%=user.getId()%> /> </td> 2.action Copy codeThe code is as follows: String[] checkbox = request.getParameterValues(“checkbox”); List<Integer> checkboxs = new ArrayList<Integer>(); int operatorId =SessionMgr.getAccountSession(request, response).getId(); logger.debug(“–operatorId–:”+operatorId); //Determine whether the check box is selectedif(checkbox!=null&&!””.equals(checkbox)){ for(int i=0;i<checkbox.length;i++){ //checkboxs.add(checkbox[i]); String id_str = checkbox[i]; […]

  • JSP radio button verification, drop-down box verification, check box verification implementation code

    Time:2021-8-31

    //Verify gender (radio button verification)function checkXb(){ var temp = false; var xbObj1= document.getElementById(“xb1”); var xbObj2= document.getElementById(“xb2”); if(xbObj1.checked || xbObj2.checked){ temp = true; } return temp; } function checkform() { //Verify gender (radio button verification)if(!checkXb()){ Alert (“please select gender”);return false; } //Verifier category (drop-down box)if(document.getElementById(“lb”).selectedIndex == 0){ Alert (“please select a personnel category”);return false; } } […]