i would like to asks some questions, recently i had to migrate our legacy application to weblogic, but some feature can't be used (multipart post form), here is my code:
noticeWrite.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<% request.setCharacterEncoding("UTF-8"); %>
<%@ page import="common.Util"%>
<%@ page import="common.Const"%>
<%
String lang_cls=Util.nullChk(request.getParameter("lang_cls"),"eng");
String sectn_nm=Util.nullChk(request.getParameter("sectn_nm"),"notice");
System.out.println("request.getContentType() ====> " + request.getContentType());
%>
<jsp:include flush="true" page="/admin/include/top_brd.jsp" />
<jsp:include flush="true" page="/admin/include/board_left.jsp" />
<form name="frm" method="post" action="noticeProc.jsp" onsubmit="return frmSubmit(this)">
<input type="hidden" name="mode" value="insert">
<input type="hidden" name="lang_cls" value="<%=lang_cls%>">
<input type="hidden" name="sectn_nm" value="<%=sectn_nm%>">
<input type="hidden" name="board_seq" value="">
<!--right start-->
<div id="subRight">
<h3><%=Const.getConstant(sectn_nm)%>
<p class="homeNevi"><img src="../.././common/home_imgs/neviHome.gif"
alt="Home" /> <span></span> Administrator <span>></span>
Data & Informasi <span>></span> <%=Const.getConstant(sectn_nm)%>
</p>
</h3>
<!--edit start-->
<div class="bleStyle_border">
<table cellspacing="0" cellpadding="3" frame="void" border="1px"
bordercolor="#b1a587" class="homeList">
<caption> </caption>
<colgroup>
<col style="width: 80px;" />
<col style="" />
<col style="width: 80px;" />
<col style="width: 260px;" />
</colgroup>
<tr>
<th scope="row">* Judul</th>
<td colspan="3"><input type="text" name="board_titl"
msg="Please type a title" maxlength="100" class="iput_txt"
style="width: 99%;" /></td>
</tr>
<tr>
<th scope="row">* Penulis</th>
<td><input type="text" name="make_nm" msg="Please type a writer"
maxlength="20" value="${sess_mbr_id}" class="iput_txt"
style="width: 97%;" /></td>
<th scope="row">File</th>
<td class="bleLeft"><input type="file" name="file_1"
class="iput_file" onkeypress="blur()" /></td>
</tr>
<tr>
<td colspan="4"><textarea cols="" rows="" name="board_cntt"
msg="Please type a content" maxlength="5000" class="bleText_area"
style="width: 98%; height: 100px;"></textarea>
<script language="JavaScript1.2">
editor_generate('board_cntt');
</script>
</td>
</tr>
</table>
</div>
<div class="bleBtn_box"><!--future extention of buttons is considered. so, buttons without class is orderly backward. be cautious!-->
<a href="javascript:goToPage('noticeList.jsp','')"><img
src="../.././common/home_imgs/daftar_btn.gif" alt="" /></a><!--daftar_btn button-->
<input type="image" src="../.././common/home_imgs/kirim_btn.gif" alt=""
class="btnLeft" /><!--kirim_btn button--></div>
</div>
<!--right start-->
</form>
<script type="text/javascript">
<!--
function frmSubmit(form){
form.encoding = "multipart/form-data";
return chkNull(form);
}
//-->
</script>
<jsp:include flush="true" page="/admin/include/board_bottom.jsp" />
noticeProc.jsp
<%@ page import="board.NoticeBoardMng"%>
<%@ page import="entity.Board"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="common.Util,
com.oreilly.servlet.MultipartRequest,
com.oreilly.servlet.multipart.DefaultFileRenamePolicy"%>
<%
request.setCharacterEncoding("UTF-8");
String savePath= Util.getMessage("filepath","NOTICE_FILE_PATH");
//System.out.println("savePath =====> " + savePath);
int sizeLimit=5*1024*1024;
//MultipartRequest multi=new MultipartRequest(request,savePath,sizeLimit,"UTF-8",new DefaultFileRenamePolicy());
MultipartRequest multi = new MultipartRequest(request,savePath,sizeLimit,"UTF-8");
String mode = Util.nullChk(multi.getParameter("mode"));
String board_seq = Util.nullChk(multi.getParameter("board_seq"));
String lang_cls = Util.nullChk(multi.getParameter("lang_cls"));
String sectn_nm = Util.nullChk(multi.getParameter("sectn_nm"));
String make_nm = Util.nullChk(multi.getParameter("make_nm"));
String board_titl = Util.nullChk(multi.getParameter("board_titl"));
String board_cntt = multi.getParameter("board_cntt");
String file_1 = Util.nullChk(multi.getFilesystemName("file_1"));
String sfield = Util.nullChk(multi.getParameter("sfield"));
String sword = Util.nullChk(multi.getParameter("sword"));
String nowPage = Util.nullChk(multi.getParameter("nowPage"));
//board_cntt=Util.transHtml(board_cntt);
Board board=new Board();
board.setBoard_seq(board_seq);
board.setLang_cls(lang_cls);
board.setSectn_nm(sectn_nm);
board.setMake_nm(make_nm);
board.setBoard_titl(board_titl);
board.setBoard_cntt(board_cntt);
board.setBoard_cntt_long(board_cntt);
if(file_1 == null){
board.setFile_1("");
}else{
board.setFile_1(file_1);
}
%>
<html>
<head>
<script language="javascript" src="/common/js/common.js"></script>
</head>
<body>
<form name="frm" method="post" action="">
<input type="hidden" name="lang_cls" value="<%=lang_cls%>">
<input type="hidden" name="sectn_nm" value="<%=sectn_nm%>">
<input type="hidden" name="board_seq" value="">
<input type="hidden" name="sfield" value="<%=sfield%>">
<input type="hidden" name="sword" value="<%=sword%>">
<input type="hidden" name="nowpage" value="<%=nowPage%>">
</form>
<%
boolean isSuccess=false;
NoticeBoardMng bMng=new NoticeBoardMng();
if("insert".equals(mode)){
isSuccess=bMng.saveBoard(board);
if(isSuccess){
out.println("<script language='javascript'>");
out.println("goToPage('noticeList.jsp','"+board_seq+"')");
out.println("</script>");
}else{
out.println("<script language='javascript'>");
out.println("alert('fail!');");
out.println("history.back();");
out.println("</script>");
}
}else if("update".equals(mode)){
isSuccess=bMng.updateBoard(board);
if(isSuccess){
out.println("<script language='javascript'>");
out.println("goToPage('noticeList.jsp','')");
out.println("</script>");
}
}
%>
</body>
</html>
The problem is, when i clicked submit button, file is stored to server but text field and text area value didn't stored to database and throws an error:
java.io.IOException: Posted content type isn't multipart/form-data
at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:130)
at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:94)
at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:219)
at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:170)
at jsp_servlet._admin._board.__noticeproc._jspService(__noticeproc.java:109)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:185)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3732)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
I need your advice, what's wrong with this? because it works fine on tomcat, but cannot run under weblogic, thank you.
edit:
from the error log, it says error on __noticeproc.java:109, here are the content:
String savePath= Util.getMessage("filepath","NOTICE_FILE_PATH"); //System.out.println("savePath =====> " + savePath); int sizeLimit=5*1024*1024; //MultipartRequest multi=new MultipartRequest(request,savePath,sizeLimit,"UTF-8",new DefaultFileRenamePolicy()); MultipartRequest multi = new MultipartRequest(request,savePath,sizeLimit,"UTF-8");
here is the parameter from firebug:
Content-Type: multipart/form-data; boundary=---------------------------2572913021633 Content-Length: 1092
-----------------------------2572913021633 Content-Disposition: form-data; name="mode"
insert -----------------------------2572913021633 Content-Disposition: form-data; name="lang_cls"
eng -----------------------------2572913021633 Content-Disposition: form-data; name="sectn_nm"
office3 -----------------------------2572913021633 Content-Disposition: form-data; name="board_seq"
-----------------------------2572913021633 Content-Disposition: form-data; name="board_titl"
TestPage -----------------------------2572913021633 Content-Disposition: form-data; name="make_nm"
agit -----------------------------2572913021633 Content-Disposition: form-data; name="file_1"; filename="" Content-Type: application/octet-stream
-----------------------------2572913021633 Content-Disposition: form-data; name="board_cntt"
testpage -----------------------------2572913021633 Content-Disposition: form-data; name="x"
57 -----------------------------2572913021633 Content-Disposition: form-data; name="y"
5 -----------------------------2572913021633--