So my purpose by this code is : by clicking on the parse button I want the path of file written in my zone text named "chemin" to be retrieved by the controller OssLogParsserenter so that i can get to this file and parse it so that what im trying to do but i got a 405 error what's wrong with my code pleaase help me ?
Ps:I DONT WANT TO USE <input type="file">
here my log import jsp file :
<%@ include file="/WEB-INF/views/includes/includes.jsp" %>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>OSS PROBLEMS - Predict and Solve</title>
<!-- Bootstrap Core CSS -->
<link href="<%=request.getContextPath() %>/resources/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- MetisMenu CSS -->
<link href="<%=request.getContextPath() %>/resources/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="<%=request.getContextPath() %>/resources/dist/css/sb-admin-2.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="<%=request.getContextPath() %>/resources/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="wrapper">
<!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
<%@ include file="/WEB-INF/views/menu_top/topMenu.jsp" %>
<%@ include file="/WEB-INF/views/menu_left/leftMenu.jsp" %>
<!-- /.navbar-static-side -->
</nav>
<!-- Page Content -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
CMExport
</div>
<div class="panel-body">
<c:url value="/logimport/parse" var ="urlparse" />
<div class="row">
<div class="col-lg-6">
<form method="post" role="form">
<div class="form-group">
<label>CMExport</label>
<input class="form-control" placeholder="Enter chemin du log" name="chemin">
</div>
<ol class="breadcrumb">
<li><a href="<c:url value="/logimport/parse" />" ><fmt:message code="common.parse" /></a></li>
</ol>
<div class="form-group">
<label>log message</label>
<textarea class="form-control" rows="3"></textarea>
</div>
</form>
</div>
<!-- /.col-lg-6 (nested) -->
</div>
<!-- /.row (nested) -->
</div>
<!-- /.panel-body -->
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="<%=request.getContextPath() %>/resources/vendor/jquery/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="<%=request.getContextPath() %>/resources/vendor/bootstrap/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="<%=request.getContextPath() %>/resources/vendor/metisMenu/metisMenu.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="<%=request.getContextPath() %>/resources/dist/js/sb-admin-2.js"></script>
</body>
</html>
here is my OssLogParser controller:
package com.oss.controllers;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.ericsson.oss.entites.Dmr_dmtool;
import com.ericsson.oss.services.IDmr_dmtoolService;
@Controller
@RequestMapping (value="/logimport")
public class OssLogParserController {
String path ;
@Autowired
private IDmr_dmtoolService Dmr_dmtoolService ;
@RequestMapping (value="/")
public String logimport() {
return "logimport/logimport";
}
@RequestMapping(value="/parse",method=RequestMethod.POST)
public String OssLogParser(HttpServletRequest request ) throws
ParseException {
path =request.getParameter("chemin");
BufferedReader br = null;
try {
String line;
br = new BufferedReader(new FileReader(path));
String nameOfLog =br.readLine().toString();
if (nameOfLog.indexOf("/dmr/dmtool")!= -1){
line = br.readLine();
line = br.readLine();
Date date = new Date() ;
DateFormat df = new SimpleDateFormat("dd-MM-
yyyy");
date=df.parse(line = br.readLine());
while ((line = br.readLine()) != null) {
if (line.indexOf("Diskgroup/Volume")!= -1) {
br.readLine();
String ligne = br.readLine();
if (ligne!= null) {
while (ligne.indexOf("Defined")== -1) {
String lo=ligne.trim();
Scanner sc =new Scanner(lo);
String a="a";
String b="b";
String c="c";
Dmr_dmtool dmrtool = new Dmr_dmtool() ;
while (sc.hasNextLine()) {
a=sc.next().toString();
if (sc.hasNext()) {
b=sc.next().toString();}
if (sc.hasNext()) {
c=sc.next().toString();}
dmrtool.setDiskgroup_volume(a);
dmrtool.setMirror_1(b);
dmrtool.setMirror_2(c);
dmrtool.setDate(date);
Dmr_dmtoolService.update(dmrtool);
}
ligne = br.readLine();
}
}
}
}
}
}
catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)
br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
return "redirect:/logimport/";
}
}
The error
The view