JAVA筆記
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 1/20 JSP 觀念 ###### tags: `JSP` # 5-60 errorpage與isErrorPage設定 ![](https://i.imgur.com/LZIxfSd.png) # 5-61.62 errorpage屬性 轉型有問題由這支errorpage="error.jsp"處理程式 ![](https://i.imgur.com/kPK0WfM.png) true exception這行印出顯示過程 ![](https://i.imgur.com/ky0HdRz.png) (errorHandler.jsp)(hello.jsp) 用chrome執行 eclipse用ie會有問題 # 5-63 web.xml設定錯誤時處理 web.xml可以用通用性設定 2邊都設通用性 會以jsp程式優先 jsp沒設就以xml優先 上面靜態 下面動態(error-code):![](https://i.imgur.com/LCvfajF.png) # 5-64 <jsp:include>標籤 include包page自行生成 add.jsp也會獨立生成 參考(5-121) ![](https://i.imgur.com/84KIsQZ.png) (paramTest1.jsp)(paramTest1.jsp) In paramTest1:->In paramTest2:->In paramTest1: http://localhost:8080/JSPDemo/paramTest1.jsp(?first=Harry&last=jjj) 看順序 ![](https://i.imgur.com/HdNwoRl.png) 參考(5-117) ![](https://i.imgur.com/GrSpEXV.png) # 5-65<jsp:forward>標籤 用forward出去就不會回來 ![](https://i.imgur.com/wd9367G.png) ![](https://i.imgur.com/iKL0V9y.png) # 5-66 jps pages XML語法化 ![](https://i.imgur.com/sjqgh70.png) # 5-67 類xml格式標籤 ![](https://i.imgur.com/kIhMlq1.png) (counter_xml.jps) # 5-68 範例(xml格式) ![](https://i.imgur.com/5634fer.png) # 5-69 Expression Language(EL) ![](https://i.imgur.com/kSSWlll.png) https://docs.oracle.com/javaee/6/tutorial/doc/gjddd.html ![](https://i.imgur.com/8Jbfqte.png) Immediate Evaluation:立即驗證 Deferred Evaluation:晚一點驗證 # 5-70 EL討論範例 黃色區塊=黃色區塊 一樣 ![](https://i.imgur.com/ZL9JWJa.png) ![](https://i.imgur.com/vDdDtxP.png) ![](https://i.imgur.com/DefH72f.png) (eldemo.jsp) ![](https://i.imgur.com/CQJL90g.png) # 5-71.72 Scripting VS.EL ![](https://i.imgur.com/M31n6RQ.png) 前面強迫轉型 context環境 上面動詞 下面名詞 字首大寫 ![](https://i.imgur.com/c7ue1C1.png) # 5-73~76 EL 對空值得處裡比較不會死當 ![](https://i.imgur.com/2SWxUMV.png) ![](https://i.imgur.com/RI5roCx.png) ![](https://i.imgur.com/PXUTOb2.png) 要強迫轉型request 才能叫出.getMethod方法 context.request算是一個子類 get動詞(動作) ![](https://i.imgur.com/Bd3Hvjx.png) 全部忽略:![](https://i.imgur.com/WMBVgFj.png) 參考5-40 ![](https://i.imgur.com/SSJk8Q4.png) ![](https://i.imgur.com/HfcmISo.png) # 5-77~83 使用EL取得屬性 我去抓一個javabean 物件:user get:proprety 取得某人的名子 登入成功 上面javabean 下面el寫法 屬性名稱.運算 ![](https://i.imgur.com/7G1NJMF.png) 陣列orlist用[] ![](https://i.imgur.com/qFiwhly.png) 泛型 變數=建構子 泛型 ![](https://i.imgur.com/gf7OuyI.png) ![](https://i.imgur.com/ZryHPCg.png) names多個名稱 ![](https://i.imgur.com/zXKAv4O.png) 索引值變數名稱 param.index getparamname 運算式 ![](https://i.imgur.com/UXIcn12.png) list name = 子類array ![](https://i.imgur.com/G2f0m4Q.png) # 5-84.85 EL的隱含物件 Implicit Objects https://www.javatpoint.com/EL-expression-in-jsp https://www.tutorialspoint.com/jsp/jsp_expression_language.htm 跟屬性有關![](https://i.imgur.com/8xpZmhI.png) # 5-86.87 EL運算子 ![](https://i.imgur.com/qV2lNHF.png) ![](https://i.imgur.com/L5AOF5g.png) # 5-89.90 Implicit Object Available in JSP Pages Implicit(隱性)<=>Explicit(顯性) exception特別的 ![](https://i.imgur.com/hMWm0dw.png) ![](https://i.imgur.com/80Crx4M.png) ![](https://i.imgur.com/uGhB71h.png) 白皮書 80 103頁 ![](https://i.imgur.com/jaYdgPU.png) ![](https://i.imgur.com/siBggbd.png) 原因:![](https://i.imgur.com/jIo4Fgf.png) # 5-91~94 Implicit Objects說明 ![](https://i.imgur.com/sCasM3k.png) 網頁看的到page scope 所在的執行環境 ![](https://i.imgur.com/g4jG5wT.png) application=context ![](https://i.imgur.com/X4d3FGC.png) ![](https://i.imgur.com/pYZeck1.png) page=this 就是自己本身 ![](https://i.imgur.com/UN8kQvJ.png) ![](https://i.imgur.com/bJ2Pq1t.png) # 5-95 Implicit Objects Available in Error Pages 選告變數 物件名稱少用這樣開頭 ![](https://i.imgur.com/TzAXOza.png) (implicit.jsp)(xml)(initTest.jsp) ![](https://i.imgur.com/uZdTNSC.png) # 5-96.97.(98) 程式碼練習 ![](https://i.imgur.com/jU89ibU.png) ![](https://i.imgur.com/SZ4ot8P.png) ![](https://i.imgur.com/9vtj8Fq.png) # 5-99 Jsp的scope物件 Application servletContext Session Session Request Request page pagecontext setAttribute() getAttribute() removeattribute() ![](https://i.imgur.com/Z27Rc5t.png) # 5-100 Scope物件 ![](https://i.imgur.com/Z8VA8ge.png) https://javaee.github.io/javaee-spec/javadocs/ ![](https://i.imgur.com/rsGffLp.png) 用靜態include 不能用同樣的宣告 # 5-102 JSP page就是servlet parse翻成java檔 ![](https://i.imgur.com/ZfQ0FtZ.png) # 5-103 JSP的life-cycle phases 七個階段 ![](https://i.imgur.com/cKj23Uc.png) # 5-104 JSP的Instance產生過程 ![](https://i.imgur.com/UJ2XSXI.png) # 5-105 JSP life-cycle中所呼叫的method 服務完實作 ![](https://i.imgur.com/GMo5dDc.png) https://javaee.github.io/javaee-spec/javadocs/ ![](https://i.imgur.com/uMYvj2Z.png) ![](https://i.imgur.com/SfebXZz.png) # 5-106.7.8 jsp to servlet ![](https://i.imgur.com/76kuWO8.png) ![](https://i.imgur.com/QV3CGzv.png) 樣板文字 out.write (visitorcounter.jsp) ![](https://i.imgur.com/4hQoEqQ.png) # 5-109 Translation units a includ b 不能重複宣告 ![](https://i.imgur.com/ikyQO9D.png) (參考5-114) # 5-110 JSP life-cycle範例 (persistent_visitorcounter.jsp) ![](https://i.imgur.com/E1oQLZA.png) # 5-111 使用request-time attribute expressions 把資訊帶進去 下面的程式要在執行階段才能執行 ![](https://i.imgur.com/30IiGup.png) # 5-113 Static inclusion 第一行 jsp寫法 第二行 xml ![](https://i.imgur.com/v6v19Gu.png) # 5-114 Static inclusion例 ![](https://i.imgur.com/aZbMPs9.png) # 5-115 Static inclusion的注意事項 上一張a跟b可擺pageContext ![](https://i.imgur.com/B9wPr9G.png) # 5-116 Dynamic inclusion page活的 flush='true'立即送出 ![](https://i.imgur.com/VmboksQ.png) # 5-117 Dynamic inclusion範例 各自有serv程式 ![](https://i.imgur.com/8EjqZpm.png) 白皮書 114(參考) ![](https://i.imgur.com/m60NhDF.png)![](https://i.imgur.com/gmavF7I.png) # 5-118.119 JSP include action說明 java語法 servlet語法 jsp include進來 include(StringrelativeUrlPath, boolean flush) include If the relativeUrlPath begins with a "/" then the URL specified is calculated relative to the DOCROOT https://javaee.github.io/javaee-spec/javadocs/ ![](https://i.imgur.com/Fu3ZTtp.png) 白皮書 ![](https://i.imgur.com/aFlk8IO.png) 靜態 ``` • A.jsp says <%@ include file=”dir/B.jsp”%> and dir/B.jsp says <%@ include file=”C.jsp”%>. In this case the relative specification C.jsp resolves to dir/C.jsp. • A.jsp says <jsp:include page=”dir/B.jsp”/> and dir/B.jsp says <jsp:include page=”C.jsp” />. In this case the relative specification C.jsp resolves to dir/ C.jsp. • A.jsp says <jsp:include page=”dir/B.jsp”/> and dir/B.jsp says <%@ include file=”C.jsp” %>. In this case the relative specification C.jsp resolves to dir/ C.jsp. • A.jsp says <%@ include file=”dir/B.jsp”%> and dir/B.jsp says <jsp:include page=”C.jsp”/>. In this case the relative specification C.jsp resolves to C.jsp. ``` 1.a->b<c=c 2.a>b>c 3.a->b=c(在b裡面) 4.a靜態->b b動態->c c=a ![](https://i.imgur.com/FkuUPsn.png) # 5-120 JSP forward action說明 forward pagecontext特異功能送出去 ![](https://i.imgur.com/7hGBQFD.png) # 5-121 傳遞參數給dynamically included compon 送參數 ![](https://i.imgur.com/wx02uwE.png) (參考5-64頁) # 5-122 與dynamically included components共享物件 (參考5-117圖) ![](https://i.imgur.com/TmBfSm2.png) # 5-124 甚麼是JavaBeans? 封裝:合法的方法,讓使用者來呼叫,做控管,跟邏輯判斷 ![](https://i.imgur.com/xApewlv.png) # 5-125 JavaBeans的設計規則 沒參數的建構子 建構子的宣告 要寫"沒有參數的建構子" 類別或成員都沒有公開的變數 JavaBean需要package player; ![](https://i.imgur.com/3HHIzuh.png)![](https://i.imgur.com/Z5z9wfZ.png) 1.![](https://i.imgur.com/PVUPwPJ.png)2.![](https://i.imgur.com/NeNr9Gq.png)3.只是一個宣告 實作implements![](https://i.imgur.com/ZWH0b6C.png) javaBeans可以把東西都包起來封裝 ![](https://i.imgur.com/CdXaAUC.png) # 5-126 Jsp tage設定JavaBeans ![](https://i.imgur.com/CWTDqbx.png)白皮書![](https://i.imgur.com/EAMN0g8.png) # 5-127.128 <jsp:useBean>的宣告項目(attribute) ![](https://i.imgur.com/iw6G2HA.png)![](https://i.imgur.com/dSCJ1z3.png) type跟class不能亂寫 type父類 ![](https://i.imgur.com/VRgM9Hu.png) # 5-129.130 <jsp:get(set)property>-讀取Bean的值 宣告 取得 property:轉化動作(參考131) siraple property index property ![](https://i.imgur.com/IWKKQWq.png)![](https://i.imgur.com/lgX36w6.png) # 5-131 範例討論 java.io.Serializable ![](https://i.imgur.com/Yh97971.png) # 5-132 ![](https://i.imgur.com/fca8lxa.png)程式碼去寫![](https://i.imgur.com/rlQGD9Q.png)javabean去寫![](https://i.imgur.com/IAP3CP2.png) # 5-133~135 範例討論 type沒寫 宣告變數名稱空的 ![](https://i.imgur.com/VvRm35k.png)![](https://i.imgur.com/V5pgJgJ.png) https://javaee.github.io/javaee-spec/javadocs/ ![](https://i.imgur.com/IpleaMs.png) # 5-136 <jsp:useBean> user.setPassword("123456") .方法 javabean沒有定義setPassword的方法javabean會當掉 大小寫要注意 ![](https://i.imgur.com/7qFWCqi.png) # 5-137 <jsp:setProperty> ![](https://i.imgur.com/WkfjMfS.png)![](https://i.imgur.com/AvvoTsf.png) # 5-138.139 <jsp:setProperty> 138跟139相對的 138 找步道user物件,則會建立一個新的物件並設定相關屬性內容,相反則會直接使用![](https://i.imgur.com/GbJG4I1.png)139 2條獨立的![](https://i.imgur.com/yzlmlql.png) # 5-140 <jsp:getProperty> 命名法則很重要 ![](https://i.imgur.com/kqTEBxH.png) # 5-141 Bean Class的安裝 第三方開發 通常擺lib底下 ![](https://i.imgur.com/vqjVteJ.png) (參考5-132)![](https://i.imgur.com/1hpFK4w.png) # 5-142~145 Bean範例 (StringBean.jsp)(StringBean.java) ![](https://i.imgur.com/I6Lgx0V.png) 3個不同的寫法![](https://i.imgur.com/UZB3H43.png)(SaleEntry.jsp)(SaleEntry1.java) import ![](https://i.imgur.com/DLbM6xo.png) ![](https://i.imgur.com/LSII7qy.png) http://localhost:8080/JSPDemo/SaleEntry1.jsp(?itemID=a1234&numltems=10&discountCode=0.8) (SaleEntry2.java) ![](https://i.imgur.com/wczDBR2.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully