初次接触开源项目:JSP Blog 笔记

1 篇文章 0 订阅
1 篇文章 0 订阅

由于想做一个自己的博客,必须站在巨人的肩膀上滴,所以初次找了一个开源的博客系统(JSP Blog)尝试先一番。

所以首先我的把他先运行咯


预先准备

本机环境

winxp,tomcat7,Myeclipse10

开源项目网址:http://www.oschina.net/p/jsp+blog

从该网址中下载以后是一个.war的包,然后把它放在tomcat的webapps下--》开启对应的tomcat

结果tomcat自动解压.war文件



预装数据库

从作者给的这个源码,很显然比较旧了

导入脚本至mysql中

该文件导入到mysql中

具体做法参照http://www.jb51.net/article/22734.htm

(注意:其中的sql代码有部分较旧,可能在较新的mysql中识别不了了)

例如:MYSQL查询语句写法 TYPE=MyISAM 太老了,将TYPE=MyISAM 全部改成ENGINE=MyISAM,mysql中MyISAM是默认存储引擎。

方法二:安装一个Mysql-Front可视化软件,拷贝执行portal.sql中的代码。


备忘录:

org.gjt.mm.mysql.Driver与com.mysql.jdbc.Driver区别(http://hi.baidu.com/nzvxsqjptmafvzr/item/2487de1b950c02a6feded5e2




package com.scce.servlet; import java.io.FileOutputStream; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class PhotoServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String type=request.getParameter("myType"); String encoding="UTF-8"; if(type.equals("upload")){ ServletInputStream sis=request.getInputStream(); int len=request.getContentLength(); int index=0; String tmp=null; boolean isFirst=true; String firstLine=null; int [] iindex=new int[1]; byte[] bytes=new byte[4096]; String filename=null; while((tmp=readLine(bytes,iindex,sis,encoding))!=null){ if(isFirst){ firstLine=tmp; isFirst=false; } index=tmp.indexOf("finename="); if(index!=-1){ String tailString = tmp.substring(index+10); if(tailString != null){ int ii=tailString.indexOf("\""); filename=tailString.substring(0,ii); } System.out.println(tmp); break; } filename=getName(filename); if(filename!=null){ filename="file.out1"; } String filepath="e:/"+filename; FileOutputStream fos=new FileOutputStream(filepath); String endFlag=firstLine.substring(0,firstLine.length()-2)+"--"+firstLine.substring(firstLine.length()-2); String contentType=readLine(bytes,iindex,sis,encoding); if(contentType!=null){ if(contentType.indexOf("Content-Type")==-1){ System.out.println(contentType); }else{ System.out.println("the head of file:"+readLine(bytes,iindex,sis,encoding)); } } boolean tt=false; int mark=0; byte[] backups=new byte[4096]; while((tmp=readLine(backups,iindex,sis,encoding))!=null){ if(endFlag.equals(tmp)){ if(mark>2){ fos.write(backups,0,mark-2); fos.flush(); } break; }else{ if(tt){ fos.write(backups,0,mark); fos.flush(); } mark=iindex[0]; for(int i=0;i<iindex[0];i++){ backups[i]=bytes[i]; } tt=true; } } } } } private String getName(String filename) { String rtn=null; if(filename!=null){ int index=filename.lastIndexOf("/"); if(index!=-1){ rtn=filename.substring(index+1); }else{ index=filename.lastIndexOf("\\"); if(index!=-1){ rtn=filename.substring(index+1); }else{ rtn=filename; } } } return rtn; } private String readLine(byte[] bytes, int[] index, ServletInputStream sis, String encoding) { try{ index[0]=sis.readLine(bytes, 0, bytes.length); if(index[0]<0){ return null; } }catch(IOException ex){ ex.printStackTrace(); } try{ if(encoding==null){ return new String(bytes,0,index[0]); }else{ return new String(bytes,0,index[0],encoding); } }catch(Exception e){ e.printStackTrace(); return null; } } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值