Web development and web development prospects

Source: Internet
Author: User

Web development and web development prospects
Dynamic Web Technology


Asp is a powerful html + javascrip + com component.
Easy to learn, easy to install, high efficiency and cgi.
It can only run on windows, making it difficult to implement enterprise-level functions: Server Clusters and Server Load balancer.
Selection of Small and Medium Projects


Php is cross-platform, free, efficient, and secure.
Complex installation and lack of enterprise-level support
(Php + mysql + linux + apache) Free and powerful.


Jsp = html + java + jsp + js
Advantage: one-time writing, running everywhere, based on java Technology
Good cross-platform performance
Support for multiple development tools
Powerful Scalability (jsp + javabean)
High complexity of jsp Products
Jsp requires high configuration of Running machines and requires more memory.


B/s
Browser ---- server ---- browser (ie)
C/s
Client ---- server ---- client (qq, msn)
Clients are self-developed.


Servlet
It is a server applet that can be called and executed by the server. It is written in java and developed according to Servlet specifications. It is the basis for learning jsp and has powerful functions.
Servlet/jsp running environment, browser + web Server tomcat + database SQL 2000, oracle, mysql


Tomcat servlet container, free of charge, good performance,
Start: in the bin directory of tomcat, double-click the start. bat file.


Printwriter pw = res. getwriter ();
Pw. println ("hello, world ");
Output on the browser


Function Description (use case diagram to describe uml (Unified Modeling Language ))
Design Database
Design Interface (Prototype Development)
<Servlet>
<Servlet-name> hello name </servlet-name>
<Servlet-class> com. c. hello path package name and class name </servlet-class>
</Servlet>


<Servlet-mapping>
<Servlet-name> hello </servlet-name>
<Url-pattern>/sp </url-pattern> Any url
</Servlet-mapping>
Servlet
Input to the screen,
PrintWriter pw = res. getWriter ();
Pw. println ("hello the world ");


Develop servlet by inheriting httpservlet
Doget and dopost must be rewritten.
Public void doGet (HttpServletRequest req, HttpServletResponse res)
{}
Req: used to obtain information about the client (browser). res: Used to return information to the client.
Public void dppost (HttpServletRequest req, HttpServletResponse res)
{
This. doGet (req, res );
}


Login ---- verification --- Welcome to f


Different servlets share data
1. cookie
2. sendRedirect (): sendRedirect ("the url of the servlet to jump? Uname = "+ cj );
3. Hide the form:
<Form action = login>
<Input type = hidden name = a value B>
</Form>
You can pass the value of name a to B to login.
In the interface where the url is login
String xex = req. getParameter ("");
Pw. println ("xex =" + xex );
4. session Technology
The session is treated as a table with two parts: the attribute name (string) and the object)
Get session
HttpSession hs = req. getSession (true );
GetId this method returns unique identifiers generated for each session. When only one single value is associated with a session, or when the log information is related to the previous sessions, it is used as a key name.


GetCreationTime returns the time when the session was created. The minimum unit is 1‰ seconds. To obtain a value that is useful for printing output, you can pass the value to the Date constructor or GregorianCalendar party.


SetTimeInMillis.


GetLastAccessedTime returns the time when the session was last sent by the customer. The minimum unit is 1‰ seconds.


GetMaxInactiveInterval returns the total time (in seconds). A negative value indicates that the session will never time out.


GetAttribute obtains the information associated with a session. (GetValue in jsp1.0)


Integer item = (Integer) session. getAttrobute ("item") // retrieves the session value and converts it to an Integer.


SetAttribute provides a keyword and a value. Will replace any previous values. (PutValue in jsp1.0)


Session. setAttribute ("ItemValue", itemName); // The ItemValue must not be of the must simple type.


Link Database


Servlet insert Image
Pw. println ("img ser = imgs/1.gif image path weight set length and width ");


Paging Technology
Int pagesize: number of records per page
Total pagecount pages
Pagenow page
Total number of rowcount records
Select field name list from table name where id? And?
However, if three records are displayed on each page, delete one of them and continue to use this query statement. Only two records are displayed on each page.


Use the following statement:
Select top pageSize field name list from table name where id not in (select top pageSize * (pageNow-1) id from table name)




Relative Path-as the name suggests, relative path is relative to the current file path. This method is generally used in the webpage.
2. absolute path-absolute path is the real path of the files or directories on your home page on the hard disk. The absolute path is the real path of files or directories on your home page on the hard disk. For example, your Perl program is stored in


C:/apache/cgi-bin, then c:/apache/cgi-bin is the absolute path of the cgi-bin directory.
In the network, all links starting with http are absolute paths. absolute paths are the real paths of files or directories on your home page on the hard disk, absolute paths are often used in the path configuration of CGI programs.


Rarely used.
Ii. special symbols used for relative paths
The following are the special symbols used to create a path and their meanings.
"./": Indicates the current directory.
"../": Indicates the directory on the previous layer.
Start with "/": indicates the root directory.
 
The root directory contains Site1 and Image/image.jpg, and the page1.html file and Site2 folder under site1. Under site2, there are page2.htmland page2image.jpg image files.
1. The file is in the current directory.
Page2.html#page2image.jpg
or
2. File directory on the previous Layer
Image.jpg under page1.html#image

Image.jpg under page2.html#image

3. File directory at the next layer
Page2image.jpg under the page1.html#site2folder

4. How can I view the image.jpg image under imageon any page?

3. Notes
A. The image path in Css. Write the image path in css. The url is the position of the image for the style file.
-- Index.html
-- Css/main.css
-- Images/1.jpg
If index.html is used to reference main.css and 1.jpg in the imagesdirectory is used in main.css:
Background: url (../images/1.jpg) *** correct
Background: url (images/1.jpg) *** Error
B. The image addresses in Js are relative to the pages that call JS.
Document. getElementById ("IMG1"). style. backgroundImage
= "Url (../Images/login.jpg )";
Iv. Advantages and Disadvantages and usage
1. Advantages of absolute path
A. If someone plagiarize the content of your website, the link will also point to your website. Some plagiarized people are lazy and will not modify the content at all. In fact, it is not limited to being copied. If someone saves your webpage to a local computer


, The Links, images, css, and js in it will still be connected to your website.
B. If the webpage location changes, the link still points to the correct URL.
2. disadvantages of absolute path:
A. It is not convenient to use absolute paths when coding, because links should point to real domain names rather than development sites.
The advantages and disadvantages of relative paths are almost the opposite of absolute paths.
3. Advantages of relative paths:
A. It is easy to move the content, and the entire directory can be moved.
B. the test method is flexible and convenient for local testing.
4. disadvantages of relative paths:
A. When some content pages are changed to their locations, the link will become invalid easily.
B. It is easy to be copied by large area collection.
5. The relative path and absolute path are similar to those in the network in the system file. The path symbol of the file is the slash "/", the network path is the opposite of the Backslash "/".
 
6. Tips: the difference between "creating a website" and "creating a virtual directory" is that some people who have used IIS will know how to create a virtual directory, which can be used to specify a directory to run ASP programs, however


The following code is similar to . Note the front slash "/" of "images". If the image cannot be called in a virtual directory, you can only create a new website. In fact


When the first character is a slash, this indicates that it is relative to the root directory of the website, but the virtual directory is always a subdirectory under the website, so it cannot be used.


VII,
(1) obtain the absolute path in the Cs class: System. web. httpContext. current. request. url. scheme + ": //" + System. web. httpContext. current. request. url. authority +


System. Web. HttpContext. Current. Request. ApplicationPath + "/";
(2) in a project, the root directory contains the JsLib/common. js file. This is a public JS file. Every page in the project calls a method for this JS file. This method is one of the Jquery-based Ajax access return lists.


Methods. The path for ajax access is Common/main. ashx in the root directory. The problem is how to ensure that the Ajax access path can be accessed in "New Website" and "virtual directory.
For example, the YHMGE/UserAdd. aspx page under the root directory.
1. view the path in "virtual directory" (Company is the virtual directory name ):
Http: // 127.0.0.1/Company/YHMGE/UserAdd. aspx
2. view the path in "New Website:
Http: // 127.0.0.1/YHMGE/UserAdd. aspx
If you want to ensure that you can access both the "New Website" and "virtual directory", you cannot write a common method to obtain the Page Based on the root directory. One idea is to use absolute paths to obtain


The root path of common. js can access the handle page. We can get the absolute path of the/JsLib/common. js file in the common. js file, and then remove the "/JsLib/common. js" section from this path, and then access


Common/main. ashx can be connected to this path.
Get the root path (based on Jquery ):
Function getRootPath (){
Var scriptObj = $ ("script [src $ = '/JsLib/common. js']");
If (scriptObj = undefined)
{
Return "";
}
Var srcBase = scriptObj. eq (0). attr ("src"). replace ("/JsLib/common. js ","");;
Return srcBase
}
 
1. view the path in "virtual directory" (Company is the virtual directory name ):
<Script src = "Http: // 127.0.0.1/Company/JsLib/common. js" type = "text/javascript"> </script>
Http: // 127.0.0.1/Company/, and connect "Common/main. http: // 127.0.0.1/Company/Common/main. ashx can be accessed smoothly
2. view the path in "New Website:
<Script src = "Http: // 127.0.0.1/JsLib/common. js" type = "text/javascript"> </script>
Http: // 127.0.0.1/, and then connect "Common/main. ashx" to get the result that Http: // 127.0.0.1/Common/main. ashx can be accessed smoothly.
Of course, the premise of this method is that the reference to JS files is an absolute path.


Successful insert
Place the image in the new folder of imgs of webroot.


Pw. println (" <br> ");









































Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.