Advertisement
Fhernd

Insert.jsp

May 26th, 2012
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.81 KB | None | 0 0
  1. <%@page contentType="text/html"%>
  2. <%@page language="java" %>
  3. <%@page import="java.sql.*"%>
  4.  
  5. <html>
  6.     <head>
  7.         <title>TinyMCE Test</title>
  8.         <script language="javascript" type="text/javascript"
  9.                  src="../jscripts/tiny_mce/tiny_mce.js"></script>
  10.         <script language="javascript" type="text/javascript">
  11.             tinyMCE.init({
  12.                 mode : "textareas",
  13.                 theme : "advanced",
  14.                 plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu",
  15.                 theme_advanced_buttons1_add_before : "save,separator",
  16.                 theme_advanced_buttons1_add : "fontselect,fontsizeselect",
  17.                 theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
  18.                 theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
  19.                 theme_advanced_buttons3_add_before : "tablecontrols,separator",
  20.                 theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print",
  21.                 theme_advanced_toolbar_location : "top",
  22.                 theme_advanced_toolbar_align : "left",
  23.                 theme_advanced_statusbar_location : "bottom",
  24.                 plugin_insertdate_dateFormat : "%Y-%m-%d",
  25.                 plugin_insertdate_timeFormat : "%H:%M:%S",
  26.                 extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
  27.                 external_link_list_url : "example_data/example_link_list.js",
  28.                 external_image_list_url : "example_data/example_image_list.js",
  29.                 flash_external_list_url : "example_data/example_flash_list.js"
  30.  
  31.             });
  32.             tinyMCE.triggerSave(false, false);
  33.             tinyMCE.execCommand("mceAddControl", true, "content");
  34.             function saveMethod() {
  35.             alert("Hello");
  36.                     //var ed = tinyMCE.get('editor1');
  37.                     //var ed = tinyMCE.get('content');
  38.                     document.myform1.storeVal.value=tinyMCE.getContent();
  39.  
  40.                     alert(document.myform1.storeVal.value);
  41.             }
  42.         </script>
  43.     </head>
  44.     <body>
  45.         <!-- form sends content to moxiecode's demo page -->
  46.         <form method="post" name="myform1">
  47.         <INPUT TYPE=HIDDEN NAME="storeVal" />
  48.                 <textarea name="content"  id="content" cols="50" rows="15">
  49.                 This is some content that will be editable with TinyMCE.</textarea>
  50.                 <input type="submit" value="Save" onclick="saveMethod()" />
  51.         </form>
  52.         <%
  53.  
  54.            String str=request.getParameter("storeVal");
  55.  
  56.            System.out.println("str((((((((((())))))))"+str);
  57.            if(str!=null)
  58.            {
  59.                try{
  60.                Connection conn = null;
  61.                Statement stmt = null;
  62.                ResultSet rs = null;
  63.                String DBName="test";
  64.                String username="root";
  65.                String pwd = "";
  66.                Class.forName("com.mysql.jdbc.Driver").newInstance();
  67.                conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=" + username + "&password=" +pwd);
  68.  
  69.                String sql = "INSERT INTO Sample (ID,Content) VALUES(?,?)";
  70.                PreparedStatement pstmt = conn.prepareStatement(sql);
  71.                pstmt.setInt(1, 500);
  72.                pstmt.setString(2, str);
  73.                pstmt.executeUpdate();
  74.                }catch(Exception e){
  75.                e.printStackTrace();
  76.                }
  77.  
  78.            }
  79.  
  80.        %>
  81.     </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement