FCKeditor + JSP configuration instance

Source: Internet
Author: User

Recently, when creating the company's website background, in order to make the published information more eye-catching and special, I decided to use an online editor to edit the content online. At that time, I thought of two solutions: ewebeditor and FCKeditor. In comparison, I decided to use FCKeditor. The following describes the specific configuration steps:

My development environment is: myeclipse6.0 + tomcat5.5

1. Required jar files

(1)fckeditor_2.6.3b.zip (2) fckeditor-java-2.4-bin.zip (3) slf4j-1.5.2.zip

Note: you must use the files of the above versions. Otherwise, page errors may occur due to mismatch. At the beginning of the test, I was depressed for a day because I didn't notice the problem.

2. Deployment File

(1) decompress fckeditor_2.6.3b.zip and copy the decompressed FCKeditor folder to the webroot directory of the web project. In this case, myeclipse may prompt that the file has an error and you don't need to worry about it.

(2) decompress fckeditor-java-2.4-bin.zip, copy the four jar files: fckeditor-java-core-2.4.jar, commons-fileupload01.2.1.jar, commons-io-1.3.2.jar, slf4j-api-1.5.2.jar to the Web-INF/lib directory, and rename the fckeditor-java-core-2.4.jar to the java-core-2.4.jar

(3) decompress the slf4j-1.5.2.zip file, copy the slf4j-simple-1.5.2.jar to the Web-INF/lib directory.

(4) deploy these five jar files in eclipse to this project.

3. Instance

(1) Create an attribute file FCKeditor In the src directory. properties. If the file does not exist or is not in the src directory, the system prompts "Teh current user isn't authorized for browsing! ", The file content is as follows: Connector. useractionimpl = net. FCKeditor. requestcycle. impl. useractionimpl

(2) modify the Web. xml file

Add a Servlet

<Servlet>
<Servlet-Name> connector </servlet-Name>
<Servlet-class>
Net. FCKeditor. connector. connectorservlet
</Servlet-class>
<Load-on-startup> 1 </load-on-startup>
</Servlet>
<Servlet-mapping>
<Servlet-Name> connector </servlet-Name>
<URL-pattern>
/FCKeditor/Editor/filemanager/connectors /*
</Url-pattern>
</Servlet-mapping>

(3) Compile the test webpage and I will post all the code:

Index. jsp

<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "GBK" %>
<% @ Taglib uri = "http://java.fckeditor.net" prefix = "fck" %>
<HTML>
<Head>


<Title> my JSP 'index. jsp 'starting page </title>
<Meta http-equiv = "Pragma" content = "no-Cache">
<Meta http-equiv = "cache-control" content = "no-Cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "Description" content = "this is my page">
<! --
<LINK rel = "stylesheet" type = "text/CSS" href = "styles.css">
-->
</Head>

<Body>
This is my JSP page. <br>
<Form name = "form1" Action = "index_ OK .jsp" method = "Post" target = "_ blank">
<Input type = "text" name = "user" id = "user" size = "50">
<Input type = "text" name = "title" id = "title" size = "80">
<Br>
<Fck: Editor InstanceName = "editordefault">
<JSP: attribute name = "value"> edit the content here: </jsp: attribute>
</Fck: Editor>
<Br>
<Input type = "Submit" value = "Submit">
</Form>
</Body>
</Html>
Index_ OK .jsp

<% @ Page contenttype = "text/html; charset = GBK" %>
<%
String ED = request. getparameter ("editordefault ");
Byte [] B = ed. getbytes ("iso-8859-1 ");
Ed = new string (B );
%>
<HTML>
<Head>
<Title>
Test FCKeditor
</Title>
</Head>
<Body>
<% = Ed %>
</Body>
</Html>

Okay. Open your browser and try it! A little progress every day !!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.