Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class publishStory extends HttpServlet{
- protected void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
- PreparedStatement pstmt = null;
- Connection cn = null;
- ResultSet rs = null;
- boolean flag = false;
- PrintWriter out = null;
- try{
- System.out.println("CALLING THE METHOD");
- Class.forName("com.mysql.jdbc.Driver");
- cn = DriverManager.getConnection("jdbc:mysql://localhost/storyboard","root","");
- BufferedReader reader = request.getReader();
- JSONParser parser = new JSONParser();
- JSONObject juser = null;
- juser = (JSONObject)parser.parse(reader);
- String welcomeStoryTitle = (String)juser.get("welcomeStoryTitle");
- String welcomeStoryWords = (String)juser.get("welcomeStoryWords");
- String query = "INSERT INTO stories (storytitle, storytext) VALUES (?,?)";
- pstmt = cn.prepareStatement(query);
- pstmt.setString(1, welcomeStoryTitle);
- pstmt.setString(2, welcomeStoryWords);
- int i = pstmt.executeUpdate();
- if(i>0)
- System.out.println(welcomeStoryTitle=" : "+welcomeStoryWords);
- else
- System.out.println("No data inserted");
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }
- app.controller('welcomeStoryPublishCtrl', ['$log','$http',function($log,$http){
- this.publishGroup = function(wsPublish){
- $http({
- method:'POST',
- url: 'http://localhost:9090/Writer/publishStory',
- header: {'Content-Type':'application/json'},
- data: wsPublish
- }).success(function(){});
- };
- }]);
- juser = (JSONObject)parser.parse(reader);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement