云自無心水自閑

          天平山上白云泉,云自無心水自閑。何必奔沖山下去,更添波浪向人間!
          posts - 288, comments - 524, trackbacks - 0, articles - 6
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          HTTP Status Codes Explained

          All valid HTTP 1.1 Status Codes simply explained.

          HTTP, Hypertext Transfer Protocol, is the method by which clients (i.e. you) and servers communicate. When someone clicks a link, types in a URL or submits out a form, their browser sends a request to a server for information. It might be asking for a page, or sending data, but either way, that is called an HTTP Request. When a server receives that request, it sends back an HTTP Response, with information for the client. Usually, this is invisible, though I'm sure you've seen one of the very common Response codes - 404, indicating a page was not found. There are a fair few more status codes sent by servers, and the following is a list of the current ones in HTTP 1.1, along with an explanation of their meanings.

          A more technical breakdown of HTTP 1.1 status codes and their meanings is available at http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html. There are several versions of HTTP, but currently HTTP 1.1 is the most widely used.

          Informational

          • 100 - Continue
            A status code of 100 indicates that (usually the first) part of a request has been received without any problems, and that the rest of the request should now be sent.
          • 101 - Switching Protocols
            HTTP 1.1 is just one type of protocol for transferring data on the web, and a status code of 101 indicates that the server is changing to the protocol it defines in the "Upgrade" header it returns to the client. For example, when requesting a page, a browser might receive a statis code of 101, followed by an "Upgrade" header showing that the server is changing to a different version of HTTP.

          Successful

          • 200 - OK
            The 200 status code is by far the most common returned. It means, simply, that the request was received and understood and is being processed.
          • 201 - Created
            A 201 status code indicates that a request was successful and as a result, a resource has been created (for example a new page).
          • 202 - Accepted
            The status code 202 indicates that server has received and understood the request, and that it has been accepted for processing, although it may not be processed immediately.
          • 203 - Non-Authoritative Information
            A 203 status code means that the request was received and understood, and that information sent back about the response is from a third party, rather than the original server. This is virtually identical in meaning to a 200 status code.
          • 204 - No Content
            The 204 status code means that the request was received and understood, but that there is no need to send any data back.
          • 205 - Reset Content
            The 205 status code is a request from the server to the client to reset the document from which the original request was sent. For example, if a user fills out a form, and submits it, a status code of 205 means the server is asking the browser to clear the form.
          • 206 - Partial Content
            A status code of 206 is a response to a request for part of a document. This is used by advanced caching tools, when a user agent requests only a small part of a page, and just that section is returned.

          Redirection

          • 300 - Multiple Choices
            The 300 status code indicates that a resource has moved. The response will also include a list of locations from which the user agent can select the most appropriate.
          • 301 - Moved Permanently
            A status code of 301 tells a client that the resource they asked for has permanently moved to a new location. The response should also include this location. It tells the client to use the new URL the next time it wants to fetch the same resource.
          • 302 - Found
            A status code of 302 tells a client that the resource they asked for has temporarily moved to a new location. The response should also include this location. It tells the client that it should carry on using the same URL to access this resource.
          • 303 - See Other
            A 303 status code indicates that the response to the request can be found at the specified URL, and should be retrieved from there. It does not mean that something has moved - it is simply specifying the address at which the response to the request can be found.
          • 304 - Not Modified
            The 304 status code is sent in response to a request (for a document) that asked for the document only if it was newer than the one the client already had. Normally, when a document is cached, the date it was cached is stored. The next time the document is viewed, the client asks the server if the document has changed. If not, the client just reloads the document from the cache.
          • 305 - Use Proxy
            A 305 status code tells the client that the requested resource has to be reached through a proxy, which will be specified in the response.
          • 307 - Temporary Redirect
            307 is the status code that is sent when a document is temporarily available at a different URL, which is also returned. There is very little difference between a 302 status code and a 307 status code. 307 was created as another, less ambiguous, version of the 302 status code.

          Client Error

          • 400 - Bad Request
            A status code of 400 indicates that the server did not understand the request due to bad syntax.
          • 401 - Unauthorized
            A 401 status code indicates that before a resource can be accessed, the client must be authorised by the server.
          • 402 - Payment Required
            The 402 status code is not currently in use, being listed as "reserved for future use".
          • 403 - Forbidden
            A 403 status code indicates that the client cannot access the requested resource. That might mean that the wrong username and password were sent in the request, or that the permissions on the server do not allow what was being asked.
          • 404 - Not Found
            The best known of them all, the 404 status code indicates that the requested resource was not found at the URL given, and the server has no idea how long for.
          • 405 - Method Not Allowed
            A 405 status code is returned when the client has tried to use a request method that the server does not allow. Request methods that are allowed should be sent with the response (common request methods are POST and GET).
          • 406 - Not Acceptable
            The 406 status code means that, although the server understood and processed the request, the response is of a form the client cannot understand. A client sends, as part of a request, headers indicating what types of data it can use, and a 406 error is returned when the response is of a type not i that list.
          • 407 - Proxy Authentication Required
            The 407 status code is very similar to the 401 status code, and means that the client must be authorised by the proxy before the request can proceed.
          • 408 - Request Timeout
            A 408 status code means that the client did not produce a request quickly enough. A server is set to only wait a certain amount of time for responses from clients, and a 408 status code indicates that time has passed.
          • 409 - Conflict
            A 409 status code indicates that the server was unable to complete the request, often because a file would need to be editted, created or deleted, and that file cannot be editted, created or deleted.
          • 410 - Gone
            A 410 status code is the 404's lesser known cousin. It indicates that a resource has permanently gone (a 404 status code gives no indication if a resource has gine permanently or temporarily), and no new address is known for it.
          • 411 - Length Required
            The 411 status code occurs when a server refuses to process a request because a content length was not specified.
          • 412 - Precondition Failed
            A 412 status code indicates that one of the conditions the request was made under has failed.
          • 413 - Request Entity Too Large
            The 413 status code indicates that the request was larger than the server is able to handle, either due to physical constraints or to settings. Usually, this occurs when a file is sent using the POST method from a form, and the file is larger than the maximum size allowed in the server settings.
          • 414 - Request-URI Too Long
            The 414 status code indicates the the URL requested by the client was longer than it can process.
          • 415 - Unsupported Media Type
            A 415 status code is returned by a server to indicate that part of the request was in an unsupported format.
          • 416 - Requested Range Not Satisfiable
            A 416 status code indicates that the server was unable to fulfill the request. This may be, for example, because the client asked for the 800th-900th bytes of a document, but the document was only 200 bytes long.
          • 417 - Expectation Failed
            The 417 status code means that the server was unable to properly complete the request. One of the headers sent to the server, the "Expect" header, indicated an expectation the server could not meet.

          Server Error

          • 500 - Internal Server Error
            A 500 status code (all too often seen by Perl programmers) indicates that the server encountered something it didn't expect and was unable to complete the request.
          • 501 - Not Implemented
            The 501 status code indicates that the server does not support all that is needed for the request to be completed.
          • 502 - Bad Gateway
            A 502 status code indicates that a server, while acting as a proxy, received a response from a server further upstream that it judged invalid.
          • 503 - Service Unavailable
            A 503 status code is most often seen on extremely busy servers, and it indicates that the server was unable to complete the request due to a server overload.
          • 504 - Gateway Timeout
            A 504 status code is returned when a server acting as a proxy has waited too long for a response from a server further upstream.
          • 505 - HTTP Version Not Supported
            A 505 status code is returned when the HTTP version indicated in the request is no supported. The response should indicate which HTTP versions are supported.

          posted @ 2010-06-23 07:16 云自無心水自閑 閱讀(2532) | 評論 (0)編輯 收藏

               摘要: 一、往串口寫數(shù)據(jù) import java.io.*; import javax.comm.*; import java.util.*; public class PortWriter {     static Enumeration ports;   ...  閱讀全文

          posted @ 2010-06-18 17:06 云自無心水自閑 閱讀(2383) | 評論 (0)編輯 收藏

          "java decompiler"是一個非常出色的java反編譯工具,詳見主頁:http://java.decompiler.free.fr/

          在myeclipse8.5中的安裝也比較簡單,下載:http://java.decompiler.free.fr/jd-eclipse/update/jdeclipse_update_site.zip
          然后把這個壓縮包解開放在myeclipse8.5的dropins目錄下,比如:C:\Programs\Genuitec\MyEclipse-8.5\dropins\jdeclipse_update_site
          重起myeclipse就行了,第一次打開class文件,可能會稍微有一點慢,要等待一小會才會反編譯出來。

          好像還有點問題

          posted @ 2010-06-17 06:18 云自無心水自閑 閱讀(3698) | 評論 (0)編輯 收藏

          操作系統(tǒng)升級到windows7之后,原來很多軟件就不能用了。對于虛擬光驅(qū)軟件,我推薦一款免費的:WinCDEmu,這是一個在SourceForge上的免費軟件。優(yōu)點是使用方便,他可以虛擬出任意多個虛擬光驅(qū),而且可以選擇手工指定盤符。只要雙擊文件,就會彈出一個對話框,詢問光驅(qū)的盤符。當(dāng)然你也可以選擇讓W(xué)inCDEmu自動選擇盤符。他支持大部分主流的文件格式:ISO, CUE, NRG, MDS/MDF, CCD, IMG


          posted @ 2010-06-16 20:08 云自無心水自閑 閱讀(444) | 評論 (0)編輯 收藏

          Recently I got a chance working with Spring security, formerly known as Acegi Security for spring. While working with the framework, I heard comments from friends and colleagues saying that spring security lacks proper documentation. So thought of sharing a little knowledge. By the way, this is first ever blog posting and kindly excuse me and let me know any errors and improvements. Spring security offers a simple configuration based security for your web applications helping you secure your web application with out littering your business logic with any security code. It provides securing URL's based on the Role (Authorities), securing your business methods based on the ACL's. The first step in hooking up the spring security to your web application is by specifying the DelegatingFilterProxy in your web.xml. springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* REQUEST INCLUDE FORWARD If you want to externalize all of your security related configuration into a separate file, you can do so and add that to your context location param. contextConfigLocation /WEB-INF/beans.xml , /WEB-INF/springSecurity.xml Now comes the part of security configuration for your application, Adding the URL security patterns is pretty simple and straight forward. Add all the URL patterns which you want to secure and add the wild card pattern at the end. You need to have some default principal and role even for non logged in users as you need to give access to pages like log in, register and forgot password kind of functionality even to non logged in users. I tried to add comments to pretty much every element which I am using here. As an example I added just a wild card intercept url which make every page of my application secure. You need to exclude different urls based on the roles. Following is my custom implementation of AuthenticationEntryPoint, which currently is not doing any thing except leveraging the commence to its super class which is the spring implementation of AuthenticationProcessingFilterEntryPoint. I hooked it to add any custom logic. public class CustomAuthenticationEntryPoint extends AuthenticationProcessingFilterEntryPoint { private static final Log logger = LogFactory.getLog(CustomAuthenticationEntryPoint.class); @Override public void commence(ServletRequest request, ServletResponse response, AuthenticationException authException) throws IOException, ServletException { super.commence(request, response, authException); } } This is my custom authentication manager which actually does the custom login of the user. It will throw an BadCredentialsException in case of invalid credentials or thorws a AuthenticationServiceException in case of a service error (Database error, SQL error or any other error). public class CustomAuthunticationManager implements AuthenticationManager { @Autowired UserManagerService userManagerService; public Authentication authenticate(Authentication authentication) throws AuthenticationException { if(StringUtils.isBlank((String) authentication.getPrincipal()) || StringUtils.isBlank((String) authentication.getCredentials())){ throw new BadCredentialsException("Invalid username/password"); } User user = null; GrantedAuthority[] grantedAuthorities = null; try{ user = userManagerService.getUser((String) authentication.getPrincipal(), (String) authentication.getCredentials()); } catch(InvalidCredentialsException ex){ throw new BadCredentialsException(ex.getMessage()); } catch(Exception e){ throw new AuthenticationServiceException("Currently we are unable to process your request. Kindly try again later."); } if (user != null) { List roles = user.getAssociatedRoles(); grantedAuthorities = new GrantedAuthority[roles.size()]; for (int i = 0; i < roles.size(); i++) { Role role = roles.get(i); GrantedAuthority authority = new GrantedAuthorityImpl(role.getRoleCode()); grantedAuthorities[i] = authority; } } else{ throw new BadCredentialsException("Invalid username/password"); } return new UsernamePasswordAuthenticationToken(user, authentication.getCredentials(), grantedAuthorities); } } At the client side (jsp), the simple configuration you need to do is post the request to"/j_spring_security_check" with parameters "j_username" and "j_password". That's pretty much all you need to do for enabling spring security to your existing web application. I will try to explain about doing the method security using ACL's and configuring the view using spring security tags in another post.

          posted @ 2010-06-11 08:12 云自無心水自閑 閱讀(1506) | 評論 (0)編輯 收藏


          作者相信ga版本將會在不久的未來發(fā)布。
          所作者透露,在新版本中會增加一個新的組件:dynamic.

          這個組件的用途是更換皮膚。在舊版本的tapestry中,由于tapestry的模板是一致的,所以要實現(xiàn)換膚相當(dāng)困難。
          但在新版本中的這個組件比較完美地解決了這個問題。
          作者自我評價這個組件是令人激動的一個新事物。


          posted @ 2010-06-03 10:31 云自無心水自閑 閱讀(1946) | 評論 (1)編輯 收藏

          現(xiàn)在打開iBatis的主頁:ibatis.apache.org會發(fā)現(xiàn)作者發(fā)布了一個新聞或者說是聲明。

          大意是因為各種原因,已經(jīng)把iBatis更名為MyBatis, 并且搬遷到Google Code中了。

          新的主頁地址是: http://www.mybatis.org

          另外,MyBatis3.0.1的正式版已經(jīng)在http://code.google.com/p/mybatis/可以下載了。

          posted @ 2010-05-24 19:58 云自無心水自閑 閱讀(3129) | 評論 (2)編輯 收藏

          4月17日,iBatis3.0的GA版本的候選版本(candidate)已經(jīng)在主頁上公布出來了(ibatis.apache.org)
          根據(jù)其描述,只有PMC的投票才會被真正的計算。但是同時又補(bǔ)充說明,其實很多PMC的投票是參考社區(qū)用戶的投票結(jié)果的。
          所以也鼓勵大家發(fā)表自己的看法,并期待大家的反饋。

          原文:
          After well over a year of development and testing effort, iBATIS 3.0 is now ready for prime time. I've uploaded the new bundles for iBATIS 3 Core and Migrations. It is this release that we'll vote on for GA status. I'll leave the vote open for a good while (maybe a couple of weeks), just to give everyone a chance to try it out. As usual, only PMC votes actually count, but many PMC members will vote based on the community votes. So please offer your feedback. Otherwise, enjoy iBATIS 3.0!

          posted @ 2010-04-20 11:21 云自無心水自閑 閱讀(1847) | 評論 (2)編輯 收藏


          在最上面添加了標(biāo)簽頁,目前分了6大塊:Java,SOA,.Net,TEST,AJAX,TSSJs
          主框架也進(jìn)行了調(diào)整,從原來的2列變成了3列,將原來在右邊的要點移到了左邊。文章占據(jù)了中間最大片的面積。最右邊是新聞。
          感覺整個界面比原來的色調(diào)要清新明亮,版塊分割的更清楚。

          posted @ 2010-03-25 10:44 云自無心水自閑 閱讀(2146) | 評論 (0)編輯 收藏

          出自伏爾泰的名句。在許多優(yōu)秀的程序員的編程習(xí)慣中,尋找解決方案就如同是尋找女友一般,總是力求完美,如果一個解決方案不夠完美的話,那么寧可舍棄也不會降低標(biāo)準(zhǔn)而采用。但是這樣的結(jié)果很有可能會是一葉障目,不見森林。
          舉個實際的例子來說,tapestry5的服務(wù)動態(tài)加載就是一個典型。
          大家知道,在Tapestry中,頁面模板的動態(tài)加載一直是其的一個宣傳點。也就是說,頁面模板如果修改了,不需要重新啟動應(yīng)用服務(wù)器,修改即時生效。但是,Tapestry卻一直沒有實現(xiàn)服務(wù)的動態(tài)加載,也就是說服務(wù)的類修改了,就必須重新啟動服務(wù)器。為什么呢,因為追求完美。
          其實很久以前在Tapestry的作者的頭腦中,包括許多的用戶都想在Tapestry中加入服務(wù)動態(tài)加載的功能,但是最后作者卻放棄了。原因是因為,在Tapestry的架構(gòu)中,服務(wù)比頁面要復(fù)雜的多,服務(wù)不是單獨存在的,他會被Inject到許多其他的服務(wù),而這些服務(wù)又會被inject到其他的服務(wù)中,最后導(dǎo)致你很難界定哪些類需要被重新加載。
          但是最近有一個人提出一個建議,為什么要實現(xiàn)完整的動態(tài)加載呢。其實只實現(xiàn)服務(wù)的實現(xiàn)類的動態(tài)加載就已經(jīng)很好了。
          確實,如果保持接口不變,只在接口具體實現(xiàn)修改的時候加載,確實大大簡化了問題,因為這樣變化范圍就被限定在單個類之內(nèi)了。雖然這樣并不完美,因為如果改變了對外接口,比如,添加了一個新的方法,或者改變了方法的簽名,還是需要重新啟動服務(wù)器。可是這樣也已經(jīng)在很大程度上提升了用戶的使用滿意度。
          正如有句古語所說:退一步海闊天空。也在此提醒自己在以后的開發(fā)過程中,盡量拓展自己的思維,不要一下子鉆到牛角尖里。

          posted @ 2010-03-19 07:40 云自無心水自閑 閱讀(3031) | 評論 (0)編輯 收藏

          僅列出標(biāo)題
          共29頁: First 上一頁 6 7 8 9 10 11 12 13 14 下一頁 Last 
          主站蜘蛛池模板: 白玉县| 永春县| 哈尔滨市| 平果县| 沁源县| 阿坝县| 石家庄市| 沾益县| 岳普湖县| 边坝县| 邢台县| 尼木县| 志丹县| 富蕴县| 洛隆县| 革吉县| 乌苏市| 中超| 嘉义市| 金昌市| 松潘县| 怀宁县| 满洲里市| 赤水市| 罗山县| 新晃| 遂平县| 南召县| 和静县| 桐城市| 蒙山县| 普兰店市| 资阳市| 河北省| 宁都县| 辉县市| 靖西县| 昭通市| 马尔康县| 洛隆县| 乌什县|