首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JSP语法,该如何处理

2013-09-11 
JSP语法我已经会java了,但我还不会jsp呢,就是不知道怎么样写jsp文件呀。请高手指点一下。[解决办法]网上的例

JSP语法
我已经会java了,但我还不会jsp呢,就是不知道怎么样写jsp文件呀。请高手指点一下。

[解决办法]
网上的例子 很多的 找个例子自己敲一下就ok了
[解决办法]
所谓的JSP也就是把HTML,JS,JAVA等套在他的格式里,你可以先把JSP的页面指令啥的看看,然后找点例子做做,有JAVA基础,上手JSP还是比较容易的
[解决办法]
页头
<%@ page language= "java " contentType= "text/html; charset=gb2312 " %>
引用错误页
<%@page errorPage = "/common/error.jsp " %>
使用javabean
<jsp:useBean id= "Pool " scope= "page " class= "test.Hello "/>
导入
<%@page import= "java.sql.* "%>
<%!-声明成员变量-%>
如: <%!String a,b,c%>
<%存放Java代码%>
如: <%
a= "aa "
if( "aa ".equals(a)){
out.println( "ok ");
//注释
}
%>



[解决办法]
找个例子,配个服务,一试便知!
[解决办法]
给个例子给你 :
<%@ include file= "/lib/shareHeader.jsp " %>
<%@ include file= "/lib/shareDBConnectionPool.jsp " %>
<%@ include file= "/lib/menuBar.jsp " %>
<%@ page import= "com.eleceltek.wf.user.* "%>
<%@ page import= "com.eleceltek.util.FieldData " %>
<script language= "Javascript " src= " <%=DEF_URL_PREFIX%> /lib/javascript.js "> </script>
<script language= "Javascript " src= " <%=DEF_URL_PREFIX%> /lib/validations.js "> </script>
<%
String items=request.getParameter( "items ");
if(items==null || Integer.parseInt(items) <1) items = "2 ";
String mode=request.getParameter( "mode ");
if(mode==null) mode= "new ";
String[] dormno=request.getParameterValues( "dormno ");
String[] address=request.getParameterValues( "address ");
String[] phone=request.getParameterValues( "phone ");
String[] facilities=request.getParameterValues( "facilities ");
String[] remarks=request.getParameterValues( "remarks ");
%>
<script language= 'javascript '>
function addline() {
document.forms[0].items.value=parseInt(document.forms[0].items.value)+1;
document.forms[0].action = "addDorm.jsp ";
document.forms[0].submit();
}
function emailPopup(mypage, myname, inField1, inField2, inField3, inField4, inField5) {
var inVal;
inVal = eval(inField1 + ".value ");
openpage = mypage + "?dormno= " + inVal + "&inField1= " + inField1 + "&inField2= " + inField2+ "&inField3= " + inField3+ "&inField4= " + inField4+ "&inField5= " + inField5 ;
//alert(openpage);
winprops = "height=400,width=500,scrollbars=yes,dependent=yes,resizable=no,toolbar=no,status=Yes,directories=no,menubar=no ";
win = window.open(openpage, myname, winprops);
if (parseInt(navigator.appVersion) > = 4) { win.window.focus(); }
}
</script>
<tr> <td>
<form name= 'addDormForm ' action= 'addDorm_process.jsp ' method= 'post '>
<table width= '750 ' cellpadding= '0 ' cellspacing= '0 '>
<tr> <th colspan= '4 '> <%=lang.getLabelValue(strLang, "dorm_maint ")%> </th> </tr>


<input type= "hidden " name= "mode " value= " <%=mode%> " >
<input type = "hidden " name = "items " value= " <%=items%> ">
</tr>
</table>
<table width= "100% " border= "0 " cellspacing= "1 " cellpadding= "1 ">
<tr>
<td class= "leftRow1C " width= '2% '> </td>
<td class= "leftRow1C " width= '10% '> <%=lang.getLabelValue(strLang, "dorm_no ")%> </td>
<td class= "leftRow1C " width= '28% '> <%=lang.getLabelValue(strLang, "address ")%> </td>
<td class= "leftRow1C " width= '15% '> <%=lang.getLabelValue(strLang, "phone ")%> </td>
<td class= "leftRow1C " width= '20% '> <%=lang.getLabelValue(strLang, "facilities ")%> </td>
<td class= "leftRow1C " width= '22% '> <%=lang.getLabelValue(strLang, "remark ")%> </td>
</tr>
<%
int count=Integer.parseInt(items);
for(int i=0;i <count;i++){
%>
<tr> <td class= "rightRow <%=i%2%> " > <%=i+1%> </td>
<td class= "rightRow <%=i%2%> " > <input type= "text " name= "dormno " size= "10 " value= ' <%=dormno!=null && dormno.length> i && dormno[i]!=null?dormno[i]: " "%> ' > &nbsp;
<a href= "javascript:void(0); " onclick= "emailPopup( 'dorm_id_search.jsp ', 'Search ',
'document.forms[0].dormno[ <%=i%> ] ', 'document.forms[0].address[ <%=i%> ] ', 'document.forms[0].phone[ <%=i%> ] ', 'document.forms[0].facilities[ <%=i%> ] ', 'document.forms[0].remarks[ <%=i%> ] ') ">
<img src= " <%=DEF_URL_PREFIX%> /images/button/search_ico.gif " border= "0 "> </a>
</td>
<td class= "rightRow <%=i%2%> "> <input type= "text " name= "address " size= "38 " value= ' <%=address!=null && address.length> i && address[i]!=null?address[i]: " "%> ' > </td>
<td class= "rightRow <%=i%2%> "> <input type= "text " name= "phone " size= "15 " value= ' <%=phone!=null && phone.length> i && phone[i]!=null?phone[i]: " "%> ' > </td>
<td class= "rightRow <%=i%2%> "> <input type= "text " name= "facilities " size= "20 " value= ' <%=facilities!=null && facilities.length> i && facilities[i]!=null?facilities[i]: " "%> '> </td>
<td class= "rightRow <%=i%2%> " > <input type= "text " size= "25 " maxlength= "25 " name= "remarks " value= ' <%=remarks!=null && remarks.length> i && remarks[i]!=null?remarks[i]: " "%> '> </td>
</tr>
<%}%>
</table>
<table width= '750 ' cellpadding= '0 ' cellspacing= '1 '>
<tr>
<th colspan= '2 '>


<a> <img src= " <%=DEF_URL_PREFIX%> /images/button/ <%=strLang.toLowerCase()%> /addline_btn.gif " border= "0 " onclick= "addline() "> </a>
<input type= "image " name= 'save ' src= ' <%=DEF_URL_PREFIX%> /images/button/ <%=strLang.toLowerCase()%> /save_btn.gif ' border= '0 '>
<input type= "image " name= 'delete ' src= ' <%=DEF_URL_PREFIX%> /images/button/ <%=strLang.toLowerCase()%> /delete_btn.gif ' border= '0 '>
<a href= ' <%=DEF_URL_PREFIX%> /jsp/dorm/dormSearch.jsp '> <image src= ' <%=DEF_URL_PREFIX%> /images/button/ <%=strLang.toLowerCase()%> /back_btn.gif ' border= '0 '> </a>
</th>
</tr>
</table>
</form>
</td> </tr>
<%@ include file= "/lib/shareFooter.jsp " %>
<%@ include file= "/lib/shareConnectionFooter.jsp " %>

[解决办法]
有一本书 < <Servlet与jsp核心编程> > 第二版 美国Marty hall Larry Brown著 赵学良翻译
里面充分讲解了什么是Servlet 以及Servlet与JSP的关系,写的非常不错 建议看一看
[解决办法]
core servlet and jsp programming 楼上所说非常好
[解决办法]
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /text.jsp(35,2) Unterminated &lt;% tag
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:130)
org.apache.jasper.compiler.Parser.parseScriptlet(Parser.java:796)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1551)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs.


我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行