FCKeditor function is really powerful, but it seems to be not sensitive to JSP, online introduction of the article is also less. Catch up with the recent study with FCKeditor upload pictures, just found a few, coupled with their own research results, quickly summed up.
First to download a fckeditor, and then the next Fckeditor.java 2.3 (Fckeditot for Java) This file is used to enable it to support JSP, I found the official website of FCKeditor, but the download address seems to be very useful, suggest to http:/ /sourceforge.net/download. There is one more thing to say on the Internet, that is, Xalan.jar,xml.apache.org is its website.
Now start setting up, first go to Tomcat->webapps to create a folder called MySite. Put the/editor and fckconfig.js in FCKeditor, Fckeditor.js, Fckstyles.xml, Fcktemplates.xml four files to the MySite folder, because other files have little meaning for us. And then copy the Web-inf directory under the Web directory in Fckeditor.java 2.3 to MySite (which has commons-fileupload.jar, fckeditor-2.3.jar,web.xml, etc.) Copy the Fckeditor.tld file under the SRC directory to mysite/web-inf/. So it supports JSP.
Here are some of the files we want to modify:
Open fckconfig.js file, modify fckconfig.defaultlanguage = ' ZH-CN ';
Replace the value of Fckconfig.linkbrowserurl with the following:
Fckconfig.linkbrowserurl = Fckconfig.basepath + "filemanager/browser/default/browser.html?" Connector=connectors/jsp/connector ";
Fckconfig.imagebrowserurl = Fckconfig.basepath + "filemanager/browser/default/browser.html?" Type=image&connector=connectors/jsp/connector ";
Fckconfig.flashbrowserurl = Fckconfig.basepath + "filemanager/browser/default/browser.html?" Type=flash&connector=connectors/jsp/connector ";
Fckconfig.linkuploadurl = Fckconfig.basepath + ' Filemanager/upload/simpleuploader? Type=file ';
Fckconfig.flashuploadurl = Fckconfig.basepath + ' Filemanager/upload/simpleuploader? Type=flash ';
Fckconfig.imageuploadurl = Fckconfig.basepath + ' Filemanager/upload/simpleuploader? Type=image ';
Open the Web.xml file under Web-inf:
Define the configuration attribute enabled in Simpleuploader as true (open File Upload function)
To add a label definition:
<taglib>
<taglib-uri>/mysite</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>
So the file is set up, then create a JSP file to try:
<%@ page contenttype= "text/html; charset=gb2312 "language=" java "import=" java.sql.* "import=" java.util.* "import=" java.text.* "errorPage=" "%>"
<%@ page language= "java" import= "com.fredck.fckeditor.*"%>
<%@ taglib uri= "/mysite" prefix= "FCK"%>
<script type= "Text/javascript" src= "/mysite/fckeditor.js" ></script>
<form method= "POST" action= "bs_bulletin_save.jsp" >
<table width= "100%" border= "0" cellspacing= "1" cellpadding= "2" >
<tr>
<TD width= "19%" bgcolor= "#F0F0F0" height= "yes" align= "right" > title:</td>
<TD width= "81%" bgcolor= "#F0F0F0" ><input type= "text" name= "title" Size= "></td>"
</tr>
<tr>
<TD width= "19%" height= "bgcolor=" "#F0F0F0" >
<div align= "Center" > Chinese Information Settings <BR><BR>
<span style= "color: #FF0000" > Support HTML (picture size width not exceeding 170 pixels) </span></div>
</td>
<TD width= "81%" bgcolor= "#F0F0F0" >
<textarea name= "Content" cols= "rows=" ></textarea>
<script type= "Text/javascript" >
var ofckeditor = new FCKeditor (' content ');
Ofckeditor.basepath = "/mysite/";
Ofckeditor.height = 400;
Ofckeditor.toolbarset = "Default";
Ofckeditor.replacetextarea ();
</script>
</td>
</tr>
<tr>
<TD width= "19%" height= "bgcolor=" "#F0F0F0" > Release time:</td>
<TD width= "81%" bgcolor= "#F0F0F0" ><input type= "text" name= "Datatimes" value= "<%=time%>" size= "a" > </td>
</tr>
<tr>
<TD colspan= "2" bgcolor= "#F0F0F0" >
<div align= "center" ><input type= "Submit" value= "Add" name= "Cmdok" > <input type= "reset" value= "Rewrite" name= "Cmdcancel" ></div></td>
</tr>
</table>
</form>
The added part of the Scarlet Letter is the call to the online editor. Now upload the map to see, prompted internal server error 500, remember the beginning, we mentioned the Xalan.jar, now put Xalan.jar into the Lib folder, turn off Tomcat again, should be easy to use ...
Note that if you want to incorporate this control into your existing Web application system, you don't need to create a new MySite, you can do this:
1, the/editor and fckconfig.js in the FCKeditor, Fckeditor.js, Fckstyles.xml, fcktemplates.xml four files directly copy to the existing Web application directory.
2, the Fckeditor.java 2.3 in the Web-inf directory Commons-fileupload.jar, Fckeditor-2.3.jar placed in the existing system in the Lib directory.
3, add the configuration information of Web.xml in Fckeditor.java 2.3 in the web.xml of the existing system and tag definition:
<taglib>
<taglib-uri>/mysite</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>
Don't forget to define the configuration attribute enabled in Simpleuploader as true to turn on file upload.
4, then the Fckeditor.tld file copy to the existing system under the web-inf/, so it can be. Of course, the location of the fckeditor.tld is not absolute, you can put it somewhere else, just specify the appropriate position in the previous label definition.
Attached: Web.xml configuration information in Fckeditor.java
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<param-value>/UserFiles/</param-value><!--The root path where the attachment is uploaded-->
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>< whether to display debug information when starting the service!---->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SimpleUploader</servlet-name>
<servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<param-value>/UserFiles/</param-value><!--The root path where the attachment is uploaded-->
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>< whether to display debug information when starting the service!---->
</init-param>
<init-param>
<param-name>enabled</param-name>
<param-value>true</param-value><!--whether to open the upload file function-->
</init-param>
<init-param>
<param-name>AllowedExtensionsFile</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFile</param-name>
<param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsImage</param-name>
<param-value>jpg|gif|jpeg|png|bmp</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsImage</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFlash</param-name>
<param-value>swf|fla</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFlash</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>/webapp/fckeditor/editor/filemanager/browser/default/connectors /jsp/connector</url-pattern><!--FCKeditor directory,/editor and Fckconfig.js, Fckeditor.js, Fckstyles.xml, Fcktemplates.xml Four files directory
</servlet-mapping>
<servlet-mapping
<servlet-name>simpleuploader</servlet-name>
<url-pattern>/webapp/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern><!-- FCKeditor directory
</servlet-mapping>
<taglib>
<taglib-uri>/home/project/law/fckeditor</taglib-uri>
&nbs