CN105224316A - Script insertion method in a kind of web application and device - Google Patents
Script insertion method in a kind of web application and device Download PDFInfo
- Publication number
- CN105224316A CN105224316A CN201510582548.6A CN201510582548A CN105224316A CN 105224316 A CN105224316 A CN 105224316A CN 201510582548 A CN201510582548 A CN 201510582548A CN 105224316 A CN105224316 A CN 105224316A
- Authority
- CN
- China
- Prior art keywords
- flow data
- script
- key word
- search
- described flow
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
The embodiment of the invention discloses the script insertion method in a kind of web application, described method comprises: after the web request receiving client transmission, judges whether to carry static file mark in described web request.If do not carry static file mark in described web request, then determine the flow data returned for described web request.In described flow data, the key word that search is preset, and by described key word, in described flow data, locate script insertion position.Finally, script is inserted into the described script insertion position in described flow data, and the flow data inserting described script is back to described client.Compared with prior art, the mode that the present invention is based on flow data realizes script to be inserted into complete in the web application of deployment.
Description
Technical field
The present invention relates to technical field of data processing, be specifically related to the script insertion method in a kind of web application and device.
Background technology
Web application be a kind of can by the application program of web access.A largest benefit of web application is the application program that user is easy to access.User only needs to install browser, does not need to install other softwares again.Script uses a kind of specific descriptive language, the executable file write according to certain form.Script usually can be called by web application and perform, and all kinds of script can realize various function respectively when called.Realizing web application to before the calling of script, the script first completed in web application inserts.
At present, the script in web application inserts to be needed before web application is deployed, and was write direct in web application by script in advance.That is, existing script inserted mode can not realize script to be directly inserted into have completed in the web application of deployment.
Summary of the invention
In view of this, the invention provides the script insertion method in a kind of web application and device, script can be inserted into and complete in the web application of deployment.
The invention provides the script insertion method in a kind of web application, described method comprises:
After the web request receiving client transmission, judge in described web request, whether to carry static file mark;
If do not carry static file mark in described web request, then determine the flow data returned for described web request;
In described flow data, the key word that search is preset;
By described key word, in described flow data, locate script insertion position;
Script is inserted into the described script insertion position in described flow data, and the flow data inserting described script is back to described client.
Preferably, described in described flow data, the key word that search is preset, comprising:
Judge the stream type of described flow data;
When described flow data is character stream, in described flow data, the key word preset by chracter search;
When described flow data is byte stream, in described flow data, the key word preset by byte search.
Preferably, described by described key word, in described flow data, locate script insertion position, comprising:
In described flow data, determine the position at described key word place;
The previous position adjacent with the position at described key word place is defined as script insertion position.
Preferably, described method also comprises:
According to the length of the flow data of described insertion script, adjust the length parameter in described flow data.
Preferably, described script is javaScript script.
Present invention also offers the script insertion apparatus in a kind of web application, described device comprises:
Receiver module, for receiving the web request that client sends;
Whether judge module, carry static file mark for judging in described web request;
Determination module, for when the result of described judge module is no, determines the flow data returned for described web request;
Search module, in described flow data, the key word that search is preset;
Locating module, for by described key word, locates script insertion position in described flow data;
Insert module, for being inserted into the described script insertion position in described flow data by described script;
Return module, for the flow data inserting script is back to described client.
Preferably, described search module comprises:
Judge submodule, for judging the stream type of described flow data;
First search submodule, for when described flow data is character stream, in described flow data, the key word preset by chracter search;
Second search submodule, for when described flow data is byte stream, in described flow data, the key word preset by byte search.
Preferably, described locating module comprises:
First determines submodule, in described flow data, determines the position at described key word place;
Second determines submodule, for the previous position adjacent with the position at described key word place is defined as script insertion position.
Preferably, described device also comprises:
Adjusting module, for the length of the flow data according to described insertion script, adjusts the length parameter in described flow data.
Preferably, described script is javaScript script.
Script insertion method in web application provided by the invention, after the web request receiving client transmission, judges whether carry static file mark in described web request.If do not carry static file mark in described web request, then determine the flow data returned for described web request.In described flow data, the key word that search is preset, and by described key word, in described flow data, locate script insertion position.Finally, script is inserted into the described script insertion position in described flow data, and the flow data inserting described script is back to described client.Compared with prior art, the mode that the present invention is based on flow data realizes script to be inserted into complete in the web application of deployment.
Accompanying drawing explanation
In order to be illustrated more clearly in the technical scheme in the embodiment of the present application, below the accompanying drawing used required in describing embodiment is briefly described, apparently, accompanying drawing in the following describes is only some embodiments of the application, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Script insertion method process flow diagram in a kind of web application that Fig. 1 provides for the embodiment of the present invention;
Script insertion apparatus structural representation in a kind of web application that Fig. 2 provides for the embodiment of the present invention;
Search module 204 structural representation that Fig. 3 provides for the embodiment of the present invention;
The structural representation of the locating module 205 that Fig. 4 provides for the embodiment of the present invention;
Fig. 5 provides a kind of web application server structural representation for the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present application, be clearly and completely described the technical scheme in the embodiment of the present application, obviously, described embodiment is only some embodiments of the present application, instead of whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not making the every other embodiment obtained under creative work prerequisite, all belong to the scope of the application's protection.
Embodiments provide the script insertion method in a kind of web application, as shown in Figure 1, the script insertion method process flow diagram in a kind of web application that Fig. 1 provides for the embodiment of the present invention, described method comprises:
S101: after the web request receiving client transmission, judges whether carry static file mark in described web request.
S102: if do not carry static file mark in described web request, then determine the flow data returned for described web request.
S103: in described flow data, the key word that search is preset.
S104: by described key word, locates script insertion position in described flow data.
S105: described script is inserted into the described script insertion position in described flow data, and the flow data inserting script is back to described client.
In S101, user sends web request by the client being provided with browser to web application server, wherein, carries URL (UniformResourceLocator, URL(uniform resource locator)) in described web request.After described web application server receives described web request, judge in described web request, whether to carry static file mark.Concrete, when to carry URL in described web request be such as end up for .js .css .jpg .jpeg .gif .png or .bmp, described web application server determines that carrying static file in this web request identifies.
In the present embodiment, for the web request of carrying static file mark, do not perform the insertion of script.
In S102, if described web application server is determined not carry static file mark in described web request, then for described web request, determine the flow data corresponding with it.Concrete, it according to the web page resources of the URL consumer positioning request of carrying in described web request, and is back to client with the form of flow data by described web application server.
In S103, after the flow data returned for described web request determined by described web application server, described web application server searches for default key word in this flow data.Such as, when the script that will insert is JavaScript script, the key word preset is then </HEAD> or </head>, </BODY> or </body>.Concrete, in the flow data determined, search for the above-mentioned key word determined.
In addition, in practical operation, there is different reading manners in the flow data for various flows type.So the present embodiment, before stream data carries out the search of key word, first judges the stream type of described flow data.Concrete, when described flow data is character stream, in described flow data, the key word preset by chracter search.When described flow data is byte stream, in described flow data, the key word preset by byte search.
In S104, described web application server, after determining the position of preset keyword in described flow data, according to the position of described key word, determines the script insertion position in described flow data.In a kind of implementation, if script is javaScript script, then described web application server is in described flow data, after determining the position at described key word place, the previous position adjacent with the position at described key word place is defined as script insertion position.That is, the position of before key word is defined as the insertion position of javaScript script by described web application server.
In S105, determine the script insertion position in described flow data when described web application server after, the script that can realize specific function write in advance is inserted into the described script insertion position in described flow data, and the flow data inserting described script is back to described client.Wherein, common Scripting language comprises Scala, JavaScript, VBScript, ActionScript, MAXScript, ASP, JSP, PHP, SQL, Perl, Shell, python, Ruby, JavaFX, Lua, AutoIt etc.In addition, specific function can be realized by compile script, write as utilized JavaScript and can realize capturing user's browsing pages data, find the function of page access bottleneck.
In practical application, because the total length inserting the flow data of script increases, so, before the flow data inserting script is back to client, adjust the length parameter in this data stream, to record the length of this data stream truly.
Embodiments provide a kind of method of carrying out script insertion in the web application completing deployment, the method carries out script insertion based on the mode of flow data.Because web application server is when loading User Page resource, be adopt the mode of data stream and client to carry out data transmission.So the embodiment of the present invention is tackled the flow data that web application server sends to client, in this flow data, insert script.After client receives the flow data inserting script, carry out page rendering by web container, just can show with the page inserting script.The script inserted in the page is sightless concerning user, and namely user cannot feel to insert script in the page, so script insertion method provided by the invention is very little for the impact of user's browsing pages.
The embodiment of the present invention additionally provides the script insertion method in another kind of web application, and described method is encapsulated as java probe.In practical application, this java probe is installed on each web application server in advance, and can determine concrete stream data processing method according to the model of each web application server.
In practical application, owing to being packaged with the method that the script that can realize in web application inserts in java probe, so for the user wanting the script insertion realized in web application, it uniquely needs the thing done to install java probe exactly in web application server.That is, this mode does not need user to be those skilled in the art, can realize the insertion of script in web application yet.
The embodiment of the present invention additionally provides the script insertion apparatus in a kind of web application, the script insertion apparatus structural representation in a kind of web application provided for the embodiment of the present invention with reference to figure 2, Fig. 2.Described device comprises:
Receiver module 201, for receiving the web request that client sends;
Whether judge module 202, carry static file mark for judging in described web request;
Determination module 203, for when the result of described judge module is no, determines the flow data returned for described web request;
Search module 204, in described flow data, the key word that search is preset;
Locating module 205, for by described key word, locates script insertion position in described flow data;
Insert module 206, for being inserted into the described script insertion position in described flow data by described script;
Return module 207, for the flow data inserting script is back to described client.
In practical application, with reference to search module 204 structural representation that figure 3, Fig. 3 provides for the embodiment of the present invention, described search module 204 comprises:
Judge submodule 301, for judging the stream type of described flow data;
First search submodule 302, for when described flow data is character stream, in described flow data, the key word preset by chracter search;
Second search submodule 303, for when described flow data is byte stream, in described flow data, the key word preset by byte search.
In addition, with reference to the structural representation of the locating module 205 that figure 4, Fig. 4 provides for the embodiment of the present invention, described locating module 205 comprises:
First determines submodule 401, in described flow data, determines the position at described key word place;
Second determines submodule 402, for the previous position adjacent with the position at described key word place is defined as script insertion position.
In practical application, in order to ensure to be back to client flow data in the accuracy of information, described device also comprises:
Adjusting module, for the length of the flow data according to described insertion script, adjusts the length parameter in described flow data.
Script in the embodiment of the present invention can be javaScript script.
Script insertion apparatus in the web application that the embodiment of the present invention provides can realize following functions: receive the web request that client sends; Judge in described web request, whether to carry static file mark; When the result of described judge module is no, determine the flow data returned for described web request; In described flow data, the key word that search is preset; By described key word, in described flow data, locate script insertion position; Described script is inserted into the described script insertion position in described flow data; The flow data inserting script is back to described client.Compared with prior art, the embodiment of the present invention can realize the insertion of script in the web application completing deployment.
Accordingly, the embodiment of the present invention also provides a kind of web application server, shown in Figure 5, a kind of web application server structural representation that Fig. 5 provides for the embodiment of the present invention, and described web application server can comprise:
Processor 501, storer 502, input media 503 and output unit 504.The quantity of the processor 1001 in described web application server can be one or more, for a processor in Fig. 5.In some embodiments of the invention, processor 501, storer 502, input media 503 are connected by bus or alternate manner with output unit 504, wherein, to be connected by bus in Fig. 5.
Storer 502 can be used for storing software program and module, and processor 501 is stored in software program and the module of storer 502 by running, thus performs various function application and the data processing of web application server.Storer 502 mainly can comprise storage program district and store data field, and wherein, storage program district can store operating system, application program etc. needed at least one function.In addition, storer 502 can comprise high-speed random access memory, can also comprise nonvolatile memory, such as at least one disk memory, flush memory device or other volatile solid-state parts.Input media 503 can be used for the numeral or the character information that receive input, and generation arranges with the user of web application server and function controls the input of relevant key signals.
Specifically in the present embodiment, processor 501 can according to following instruction, executable file corresponding for the process of one or more application program is loaded in storer 502, and is run the application program be stored in storer 502 by processor 501, thus realize various function:
After the web request receiving client transmission, judge in described web request, whether to carry static file mark;
If do not carry static file mark in described web request, then determine the flow data returned for described web request;
In described flow data, the key word that search is preset;
By described key word, in described flow data, locate script insertion position;
Script is inserted into the described script insertion position in described flow data, and the flow data inserting described script is back to described client.
Preferably, described in described flow data, the key word that search is preset, comprising:
Judge the stream type of described flow data;
When described flow data is character stream, in described flow data, the key word preset by chracter search;
When described flow data is byte stream, in described flow data, the key word preset by byte search.
Preferably, described by described key word, in described flow data, locate script insertion position, comprising:
In described flow data, determine the position at described key word place;
The previous position adjacent with the position at described key word place is defined as script insertion position.
Preferably, described method also comprises:
According to the length of the flow data of described insertion script, adjust the length parameter in described flow data.
Preferably, described script is javaScript script.
For device embodiment, because it corresponds essentially to embodiment of the method, so relevant part illustrates see the part of embodiment of the method.Device embodiment described above is only schematic, the wherein said unit illustrated as separating component or can may not be and physically separates, parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of module wherein can be selected according to the actual needs to realize the object of the present embodiment scheme.Those of ordinary skill in the art, when not paying creative work, are namely appreciated that and implement.
It should be noted that, in this article, the such as relational terms of first and second grades and so on is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, article or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, article or equipment.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment comprising described key element and also there is other identical element.
Script insertion method in a kind of web application provided the embodiment of the present invention above and device are described in detail, apply specific case herein to set forth principle of the present invention and embodiment, the explanation of above embodiment just understands method of the present invention and core concept thereof for helping; Meanwhile, for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.
Claims (10)
1. the script insertion method in web application, is characterized in that, described method comprises:
After the web request receiving client transmission, judge in described web request, whether to carry static file mark;
If do not carry static file mark in described web request, then determine the flow data returned for described web request;
In described flow data, the key word that search is preset;
By described key word, in described flow data, locate script insertion position;
Script is inserted into the described script insertion position in described flow data, and the flow data inserting described script is back to described client.
2. method according to claim 1, is characterized in that, described in described flow data, the key word that search is preset, and comprising:
Judge the stream type of described flow data;
When described flow data is character stream, in described flow data, the key word preset by chracter search;
When described flow data is byte stream, in described flow data, the key word preset by byte search.
3. method according to claim 1, is characterized in that, described by described key word, locates script insertion position, comprising in described flow data:
In described flow data, determine the position at described key word place;
The previous position adjacent with the position at described key word place is defined as script insertion position.
4. method according to claim 1, is characterized in that, described method also comprises:
According to the length of the flow data of described insertion script, adjust the length parameter in described flow data.
5. method according to claim 1, is characterized in that, described script is javaScript script.
6. the script insertion apparatus in web application, is characterized in that, described device comprises:
Receiver module, for receiving the web request that client sends;
Whether judge module, carry static file mark for judging in described web request;
Determination module, for when the result of described judge module is no, determines the flow data returned for described web request;
Search module, in described flow data, the key word that search is preset;
Locating module, for by described key word, locates script insertion position in described flow data;
Insert module, for being inserted into the described script insertion position in described flow data by described script;
Return module, for the flow data inserting script is back to described client.
7. device according to claim 6, is characterized in that, described search module comprises:
Judge submodule, for judging the stream type of described flow data;
First search submodule, for when described flow data is character stream, in described flow data, the key word preset by chracter search;
Second search submodule, for when described flow data is byte stream, in described flow data, the key word preset by byte search.
8. device according to claim 6, is characterized in that, described locating module comprises:
First determines submodule, in described flow data, determines the position at described key word place;
Second determines submodule, for the previous position adjacent with the position at described key word place is defined as script insertion position.
9. device according to claim 6, is characterized in that, described device also comprises:
Adjusting module, for the length of the flow data according to described insertion script, adjusts the length parameter in described flow data.
10. device according to claim 6, is characterized in that, described script is javaScript script.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510582548.6A CN105224316A (en) | 2015-09-14 | 2015-09-14 | Script insertion method in a kind of web application and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510582548.6A CN105224316A (en) | 2015-09-14 | 2015-09-14 | Script insertion method in a kind of web application and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105224316A true CN105224316A (en) | 2016-01-06 |
Family
ID=54993313
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510582548.6A Pending CN105224316A (en) | 2015-09-14 | 2015-09-14 | Script insertion method in a kind of web application and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105224316A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115981797A (en) * | 2023-03-21 | 2023-04-18 | 北京时代新威信息技术有限公司 | Method and equipment for dynamically loading webpage in JavaFX application program |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101154231A (en) * | 2007-07-09 | 2008-04-02 | 孟智平 | Method and system for applying web page semantics |
US20080294716A1 (en) * | 2007-05-25 | 2008-11-27 | Microsoft Corporation | Ad-funded web services |
CN102065145A (en) * | 2010-12-31 | 2011-05-18 | 华为技术有限公司 | Information issuing method, device and system |
CN102306120A (en) * | 2010-07-21 | 2012-01-04 | 微软公司 | Measuring actual end user performance and availability of web applications |
-
2015
- 2015-09-14 CN CN201510582548.6A patent/CN105224316A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080294716A1 (en) * | 2007-05-25 | 2008-11-27 | Microsoft Corporation | Ad-funded web services |
CN101154231A (en) * | 2007-07-09 | 2008-04-02 | 孟智平 | Method and system for applying web page semantics |
CN102306120A (en) * | 2010-07-21 | 2012-01-04 | 微软公司 | Measuring actual end user performance and availability of web applications |
CN102065145A (en) * | 2010-12-31 | 2011-05-18 | 华为技术有限公司 | Information issuing method, device and system |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115981797A (en) * | 2023-03-21 | 2023-04-18 | 北京时代新威信息技术有限公司 | Method and equipment for dynamically loading webpage in JavaFX application program |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110968824B (en) | Page data processing method and device | |
CN106970873A (en) | Mock method of testings, apparatus and system on line | |
CN104428765A (en) | Reducing redirects | |
CN111600885A (en) | SQL injection vulnerability detection method and device, equipment and storage medium | |
CN108399088A (en) | Page display method, user terminal, page server and style configuration server | |
CN111241040B (en) | Information acquisition method and device, electronic equipment and computer storage medium | |
CN104468655A (en) | Method and system for testing reverse proxy software | |
CN109299152B (en) | Suffix array indexing method and device for real-time data stream | |
CN112434117A (en) | WebGIS visualization configuration method and system based on Vue | |
CN106201865A (en) | A kind of application programming interface API method of testing, device and terminal unit | |
CN105630927A (en) | Link generation method and apparatus | |
CN105468412A (en) | Dynamic packaging method and dynamic packaging device | |
CN110825764B (en) | SQL script generation method, system, storage medium and processor | |
CN105224316A (en) | Script insertion method in a kind of web application and device | |
CN111949312B (en) | Packaging method and device for data module, computer equipment and storage medium | |
CN107704464B (en) | Method and device for analyzing path of static resource | |
CN105469437A (en) | Client-side Flash film manufacturing method, device and system | |
CN102970380A (en) | Method for acquiring media data of cloud storage files and cloud storage server | |
CN108268369A (en) | Test data acquisition methods and device | |
CN103258055A (en) | Device and method for file downloading | |
CN116185825A (en) | Front-end self-test method, front-end device, and computer-readable storage medium | |
CN116208676A (en) | Data back-source method, device, computer equipment, storage medium and program product | |
CN110968888B (en) | Data processing method and device | |
CN110851746B (en) | Crawler seed generation method and device | |
CN109726346B (en) | Page component processing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20160106 |
|
RJ01 | Rejection of invention patent application after publication |