Javax. naming. NameNotFoundException: Name jdbc is not bound in this Context
Solution: configuration errors in the context. xml file under the META-INF or the name does not reference. Name, such as label, can only be context.
Java. lang. IllegalStateException/Attempt to clear a buffer that's already been flushed
Severe: Servlet. service () for servlet jsp threw exception
Java. lang. IllegalStateException
Solution: Add return after response. sendRedirec (a. jsp) or change the path to./a. jsp. However, none of them work. The solution is to set the buffer size: <% @ page buffer = "10kb" %> the default value is 8 KB. After you manually change it to 10 KB, there is no error.
? The type Date is ambiguous
Cause:
<% @ Page import = "java. SQL. *" %>
<% @ Page import = "java. util. *" %>
Both classes have Date, and the system does not know which one to choose.
Solution: You can use java. util. Date today = new Date (); To differentiate
? (1) MySQL plug-in garbled: MySQL installation of their own by default is the use of UTF-8, in JSP to input the data to be inserted, you can use new String (request. getParameter (string ). getBytes ("ISO8859-1"), "UTF-8"); no garbled characters after insertion ...... Use: String url = "jdbc: mysql: // localhost: 3306/database? UseUnicode = true & characterEncoding = UTF-8 ";
(2) page garbled characters: non-English languages are prone to garbled characters, especially when performing form submission detection, for example, "save ". equals (str) may not be recognized. It is best to use a hidden form for submission and set the value to a number. If multiple forms are submitted, you can use JavaScript to detect and set the value of the hidden form:
<Script type = "text/javascript">
Function getAction (num ){
Document. getElementById ("hide"). value = num;
}
</Script>
<Form>
<Input name = "action" type = "hidden" value = "" id = "hide">
<Input type = "submit" onClick = "getAction (1)" name = "value =" save "style =" width: 70px "/>
<Input type = "submit" onClick = "getAction (2)" name = "value =" too many bytes "style =" width: 70px "/>
<Input type = "submit" onClick = "getAction (3)" name = "" value = "Adjust margin" style = "width: 70px"/>
</Form>
Add
<% @ Page lpageEncoding = "UTF-8" %> <! -- Shift_jis -->
<% @ Page contentType = "text/html; charset = UTF-8" %>
<%
Request. setCharacterEncoding ("UTF-8 ");
Response. setCharacterEncoding ("UTF-8 ");
%> Can also prevent garbled characters to some extent.
<Input type = "text" name = "name" id = "name" value = <% = bean. getName () %> size = "12" maxlength = "12"/>
As shown above, input obtains the data of the database bean through the value attribute.
? This is not the case when it is changed to textarea. (Of course, you can print the data in the database using the out method)
Solution:
? I thought of a news-related website a few months ago. At that time, the textarea tag was also used.
The following is an example:
<Textarea type = "text" name = "contents"> <% = bean. getContents () %> </textarea>
Place the required data in the middle of the tag!