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

📄

📁 一些jsp源代码 内含完整jsp程序 希望大家喜欢!!!!!!!!!!!!!!!!!!!1
💻
字号:
范例default.jsp源代码:
 

图9.6 会务管理系统首页

001<%@ page errorPage="ErrPage.jsp"
002         import="Java.util.Date, Java.sql.*"
003         contentType="text/html;charset=gb2312"%>
004<JSP:useBean id="pool" scope="application" class="com.PoolBean"/>
005   <!--利用JAVABEAN连接数据库-->
006<%
007//验证用户是否为注册用户
008String strLoginUser = (String)session.getAttribute("LoginUser");
009if (strLoginUser == null || strLoginUser.length() == 0)	
010	response.sendRedirect("Login.jsp");	
011%>
012<HTML>
013<HEAD>
014<LINK REL="stylesheet" HREF="littleproject.css" TYPE="text/css">
015<TITLE>会务管理首页</TITLE>
016</HEAD>
017<BODY bgcolor=LightBlue>
018<%
019try{	 
020    //得到注册用户的用户名
021    //String strLoginUser = (String)session.getAttribute("LoginUser");	
022    if (pool.getConnectionSize() == 0)
023	{
024		pool.initializePool();
025	}
026	Connection con = null;
027	Statement stmt = null;
028    ResultSet  rs=null;		
029	int PageSize = 10; //设置每张网页显示十条记录
030	int ShowPage = 1; //设置欲显示的页数
031	int RowCount = 0; //ResultSet的记录笔数
032	int PageCount = 0; //ResultSet分页后的总页数
033	int p,m,n;
034	double box_1=0;
035	double box_2=0;
036	double box_3=0;
037	double box_4=0;			
038       con = pool.getConnection();
039	stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
040				   ResultSet.CONCUR_READ_ONLY);
041	//建立Statement对象, 并设置记录指标类型为可前后移动
042	String sql=null;
043	String search_txt="";
044	String ToPage = request.getParameter("ToPage");
045	String box_title="";
046	String box_begintime="";
047	String box_endtime="";
048	String box_place="";
049	if (request.getParameter("box_title") != null 
050     && !request.getParameter("box_title").equals(""))
051	{
052	    box_title= new 
053       String(request.getParameter("box_title").trim().getBytes("8859_1"));
054		if (box_title != null  && !box_title.equals(""))
055		{
056		    box_1=Double.parseDouble(box_title);
057		}
058	}
059	if (request.getParameter("box_begintime") != null 
060       && !request.getParameter("box_begintime").equals(""))
061	{
062	    box_begintime= new 
063    String(request.getParameter("box_begintime").trim().getBytes("8859_1"));
064		if (box_begintime != null  && !box_begintime.equals(""))
065		{
066		    box_2=Double.parseDouble(box_begintime);
067		}
068    }
069	if (request.getParameter("box_endtime") != null 
070     && !request.getParameter("box_endtime").equals(""))
071	{
072	     box_endtime= new 
073     String(request.getParameter("box_endtime").trim().getBytes("8859_1"));
074		if (box_endtime != null  && !box_endtime.equals(""))
075		{
076		    box_3=Double.parseDouble(box_endtime);
077		}
078	}		
079	if (request.getParameter("box_place") != null 
080      && !request.getParameter("box_place").equals(""))
081	{
082	    box_place= new 
083     String(request.getParameter("box_place").trim().getBytes("8859_1"));
084		if (box_place != null  && !box_place.equals(""))
085		{
086		    box_4=Double.parseDouble(box_place);
087		}
088	}		
089	if (request.getParameter("search_txt") != null
090      && !request.getParameter("search_txt").equals(""))
091	{
092	    search_txt = new 
093    String(request.getParameter("search_txt").trim().getBytes("8859_1"));
094	}		
095	if (search_txt != null  && !search_txt.equals(""))   //
096	{		 
097	  if(box_1==0 && box_2==0 && box_3==0 && box_4==0)
098	  {
099	    sql="select * from meeting where num like '%" + search_txt + "%'";
100		sql=sql + " or title like '%" + search_txt + "%'";
101		sql=sql + " or begin_time like '%" + search_txt + "%' or end_time like '%" 
102               + search_txt + "%'";			
103		sql=sql + " or place like '%" + search_txt + "%'";
104		sql=sql + "order by num";			
105	  }
106	  else
107	  {		    
108		 sql="select * from meeting where";			 
109		 if(box_1==1)
110		 {
111		     sql=sql + " title like '%" + search_txt + "%'";				 
112		 }			 
113		 if(box_2==1)
114		 {
115			  if(box_1==0)
116			  {
117			     sql=sql + " begin_time like '%" + search_txt + "%'";
118			  }
119			  else
120			  { 
121			     sql=sql + " or begin_time like '%" + search_txt + "%'";	
122			  }
123		   }			   
124		  if(box_3==1)
125		  {
126			  if(box_1==0 && box_2==0)
127			  {
128			     sql=sql + " end_time like '%" + search_txt + "%'";
129			  }
130			  else
131			  {
132			     sql=sql + " or end_time like '%" + search_txt + "%'";
133			  }
134		 }			 		
135		 if(box_4==1)
136		 {
137			  if(box_1==0 && box_2==0 && box_3==0 )
138			  {
139			     sql=sql + " place like '%" + search_txt + "%'";
140			  }
141			  else
142			  {
143			      sql=sql + " or place like '%" + search_txt + "%'";
144			  }
145		  }	
146		   sql=sql + "order by num";					  
147		}
148	}
149	else
150	{
151	   sql="SELECT * FROM meeting order by num";
152	}		
153	rs = stmt.executeQuery(sql);
154	rs.last(); //将指标移至最后一笔记录
155	RowCount = rs.getRow(); //取得ResultSet中记录的笔数	
156	PageCount = ((RowCount % PageSize) == 0 ? 
157			(RowCount/PageSize) : (RowCount/PageSize)+1);
158	//计算显示的页数
159	//判断是否可正确取得ToPage参数, 
160	//可取得则表示JSP网页应显示特定分页记录的语句		
161	if(ToPage != null)
162	{
163	    //取得指定显示的分页页数	
164		ShowPage = Integer.parseInt(ToPage);
165		//下面的if语句将判断用户输入的页数是否正确
166		if(ShowPage > PageCount)
167		{ 
168		    //判断指定页数是否大于总页数, 是则设置显示最后一页
169			ShowPage = PageCount;
170		}
171		else if(ShowPage <= 0)
172		{ //若指定页数小于0, 则设置显示第一页的记录
173			ShowPage = 1;
174		}
175	}
176	rs.absolute((ShowPage - 1) * PageSize + 1); 
177	//计算欲显示页的第一笔记录位置
178%>
179<center>
180<table border="0" width="800">
181	<tr>
182	  <td>
183	    <font size="6" face="隶书">会议管理系统首页</font>
184	  </td>
185	  <td align="right">
186	    <a href="User_update.jsp">修改个人资料</a>
187		&nbsp;&nbsp;&nbsp;&nbsp;
188		<a href="User_delete.jsp">删除个人资料</a>
189	  </td>
190	</tr>
191   	<tr>
192      <td width="600" height="10">  
193	  <%
194	      if (search_txt != null  && !search_txt.equals(""))
195		  {
196	  %>
197	  以下是包含关键字<font color="#ff0000"><%=search_txt%></font>的所有信息
198	  <%
199	      }
200	      else
201		  {
202	  %>
203	          以下是所有的信息
204	  <%
205	      }
206	  %>
207   共:<font color="blue"><%=RowCount%></font>共<font color="blue">
208    <%=PageCount%></font>页当前页为第<font color="red"><%=ShowPage%>
209     </font>页     
210    <%
211       if (PageCount>1)
212	  {
213	    if (ShowPage-3>0) 
214	      {
215		     m=ShowPage-3; 
216	      }
217		else 
218		{
219		   m=1;
220		}
221	    if (ShowPage+3<PageCount)
222		{
223		    n=ShowPage+3;
224		}
225		else 
226		{
227		   n=PageCount;
228		}
229	  %>         
230      转到页码:[                                                                                              
231      <%
232	    for( p=m;p<=n;p++)
233		{
234	      if( ShowPage==p )
235		  {
236	  %>            
237           <font color="red"><b><%=p%></b></font>             
238      <%
239	       }		   
240		   else
241		   {
242	  %>                      
243              <a <%
244			        if (ShowPage==p)
245					{%>
246					style="color:red"
247					<%
248					  }
249					%> 			
250	href="default.jsp?ToPage=<%=p%>&search_txt=<%=search_txt%>
251    &box_title=<%=box_title %>
252    &box_begintime=<%=box_begintime %>&box_endtime=<%=box_endtime%>
253    &box_place=<%=box_place %>"><%=p%></a>                                                                                     
254      <%
255	        }
256		  }
257	  %>
258      ]           
259      <%
260	    }
261	  %>                                                                                                                                                  
262     </td>
263	 <td width="200" align="right">
264	   <img border="0" src="images/enter.gif" width="30" height="30">
265	   <a href="Login.jsp">
266	      退出
267		</a>
268	 </td>               
269    </tr>  
270</table>
271<TABLE border=1 bordercolor=RoyalBlue bgcolor=LightBlue width=800>
272  <tr>
273    <TD bgcolor=LightYellow width=50 align=center>序号</TD>
274	<TD bgcolor=LightYellow width=250 align=center>会议主题</TD>
275	<TD bgcolor=LightYellow width=100 align=center>起始日期</TD>
276	<TD bgcolor=LightYellow width=100 align=center>结束日期</TD>
277	<TD bgcolor=LightYellow width=200 align=center>会议地址</TD>
278	<TD bgcolor=LightYellow width=100 align=center>会议名单</TD>
279  </tr>
280<%
281//利用For循环配合PageSize属性输出一页中的记录
282for(int i = 1; i <= PageSize; i++)
283{     
284   int select_id = rs.getInt("id");
285   int select_num = rs.getInt("num");
286   String select_title= rs.getString("title");
287   String selectbegintime= rs.getString("begin_time") ;
288   String selectendtime= rs.getString("end_time");    
289   String select_place= rs.getString("place");    
290   String select_begintime = selectbegintime.substring(0,10);
291   String select_endtime = selectendtime.substring(0,10);
292   out.println("<TR>");
293   out.println("<TD align=center width=50>" + select_num +"</TD>");
294   out.println("<TD align=center width=250>
295   <a href=meeting_detail.jsp?num="+select_num+">" + select_title +"</a>
296    </TD>");
297   out.println("<TD align=center width=100>" + select_begintime +"</TD>");
298   out.println("<TD align=center width=100>" + select_endtime +"</TD>");	   
299   out.println("<TD align=center width=200>" + select_place +"</TD>");   
300   out.println("<TD align=center width=100>
301   <a href=meeting_person_list.jsp?num="+select_num+">与会名单</a>
302   </TD>"); 
303   out.println("</TR>");
304   if(!rs.next()) 	//判断是否到达最后一笔记录
305       break;  //跳出for循环
306}
307%>
308</TABLE>
309<TABLE border="0" width="700">
310<TR valign=baseline align=center>
311<td width=500>&nbsp;</td>
312<%
313if(ShowPage != 1)
314{
315	%>
316	<TD Width=50>
317	<A Href=default.jsp?ToPage=<%= 1 %>
318   &search_txt=<%=search_txt%>&box_title=<%=box_title %>
319   &box_begintime=<%=box_begintime %>&box_endtime=<%=box_endtime%>
320   &box_place=<%=box_place %>>第一页</A>
321	</TD>
322	<TD Width=50>
323	<A Href=default.jsp?ToPage=<%= ShowPage - 1 %>
324    &search_txt=<%=search_txt%>&box_title=<%=box_title %>
325   &box_begintime=<%=box_begintime %>&box_endtime=<%=box_endtime%>
326   &box_place=<%=box_place %>>上一页</A>
327	</TD>
328	<%
329}
330if(ShowPage != PageCount)
331{
332	%>	
333	<TD Width=50>
334	<A Href=default.jsp?ToPage=<%= ShowPage + 1%>&search_txt=<%=search_txt%>
335     &box_title=<%=box_title %>&box_begintime=<%=box_begintime %>
336     &box_endtime=<%=box_endtime%>&box_place=<%=box_place %>>下一页</A>
337	</TD>  
338	<TD Width=50>
339	<A Href=default.jsp?ToPage=<%= PageCount %>&search_txt=<%=search_txt%>
340    &box_title=<%=box_title %>&box_begintime=<%=box_begintime %>
341   &box_endtime=<%=box_endtime%>&box_place=<%=box_place %>>最后页</A>
342	</TD>
343	<%
344}
345%>
346</TR>
347</TABLE>
348<%
349String user_name="";
350if (strLoginUser != null && strLoginUser.length() != 0)
351{
352   sql="select name from user where code ='"+strLoginUser+"'";
353   rs = stmt.executeQuery(sql);
354   if(rs.next())
355   {
356      user_name=rs.getString("name");
357   }
358}
359%>
360<font color=red>欢迎你:<%=user_name%></font>
361<br>
362<%
363if(strLoginUser.equals("admin"))
364{
365%>
366<a href="admin/manager_meeting.jsp">会议管理</a>&nbsp;&nbsp;
367<a href="admin/manager_meeting_person_default.jsp">会议人员管理</a>
368<a href="admin/manager_user.jsp">注册人员管理</a>
369<%
370}
371%>
372<FORM action=default.jsp method=POST>  
373  <table border="0" width="800" align="center" cellspacing="0">                                                                
374    <tr>   
375	  <td align="center">    
376	     <input type="checkbox" name="box_title" value="1">会议主题
377		 <input type="checkbox" name="box_begintime" value="1">开始日期
378		 <input type="checkbox" name="box_endtime" value="1">结束日期
379		 <input type="checkbox" name="box_place" value="1">会议地址
380      </td>
381	</tr>
382	<tr>
383      <td width="700" align="center"><img border="0" 
384              src="images/search.gif" width="30" height="25">  
385        信息关键字搜索:          
386     <input type="text" name="search_txt" size="17" value="<%=search_txt%>">             
387     <input type="submit" value="搜索" name="B1">             
388      </td>                                                                  
389    </tr>                                                                  
390    <tr>                                                                  
391      <td width="700" align="center">
392	    <font color="red">(如果关键字内容为空则列出所有信息)</font>
393      </td>                                                                 
394    </tr>                                                                 
395  </table>                                                                 
396</form> 
397</CENTER>
398<%
399	if (rs != null) rs.close();
400	pool.releaseConnection(con);
401}
402catch(Exception e)
403{
404	System.out.println("Exception: " + e.getMessage());
405}
406 %>
407</BODY>
408</HTML>

⌨️ 快捷键说明

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