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

📄 result.jsp

📁 jsp做的一个个人网站
💻 JSP
字号:
<%@ page contentType="text/html;charset=gb2312" import="java.io.*" errorPage="err.jsp" %>
<%
	request.setCharacterEncoding("gb2312");
	String choice=request.getParameter("ch");
	String button=request.getParameter("bt");
	
	
	if (button.equals("查看"))
	{
		response.sendRedirect("showresult.jsp");
		
	}
	
	else
	{
		if (session.getAttribute("FLAG")!=null)
		{
			out.print("<script>alert('您已经投过票了,短时间内不能进行两次操作!');location.href='index.jsp';</script>");
			//out.print("执行到此");
		}else{
		if (choice!=null)
		{			
			
			File file=new File (config.getServletContext().getRealPath(".")+"/myweb//result01.txt");
			
			FileInputStream fin=new FileInputStream(file);
			
			BufferedReader in=new BufferedReader(new InputStreamReader(fin));
			
			String result=in.readLine();
			int begin=result.indexOf(choice);
			int end=result.lastIndexOf(choice);
			int num=Integer.parseInt(result.substring(begin+choice.length(),end));
			
			String str=result.replaceAll(choice+num+choice,choice+(++num)+choice);
			//right above
			
			FileOutputStream fout=new FileOutputStream(file);
			
			fout.write(str.getBytes());
			fin.close();
			in.close();
			fout.close();
			
			session.setAttribute("FLAG","DONE");
			out.print("<script>alert('感谢您的参与!');location.href='showresult.jsp';</script>");

		}
		else
		{
			out.print("<script>alert('请先选择您的意见!');location.href='index.jsp';</script>");
		}
		
		}	
		
	}	
%><a href="index.jsp">返回
</a>

⌨️ 快捷键说明

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