LabVIEW Web UI Builder and Data Dashboard

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Not possible to activate Scripting on the Web Server

Solved!
Go to solution
Highlighted

Not possible to activate Scripting on the Web Server

Hi,

 

I would like to create a .html page for the Web Services with a little ESP scripting included - for now I have simply included this:

 <% for (i=0; i<3; i++) {
  ...some text...
 } %> 

 

According to this NI Paper, I must first activate scripting:

To use scripting with a Web service, you must activate the functionality on the LabVIEW Web Server. In LabVIEW, select Scripting on the Web Server: Configuration page in the Options dialog box to activate scripting on the Web Server.

 

I have enabled the Web Server and it works OK. But there is no item called "Scripting" in the configuration page - and the script is not executed (the code is just printed as simple text).

Anyone knows how to enable ESP scripting ?

Version: LV 2012.

 

Best regards, Jan

Jan Nielsen
Freelance system analyst and LabVIEW programmer
0 Kudos
Message 1 of 5
(6,273 Views)

Re: Not possible to activate Scripting on the Web Server

You shouldn't need to activate scripting.  Perhaps that document is out of date.  You need to set your web method VI to be using the Streaming output type rather than the terminal output type (this is done in the build specification in LabVIEW 2013, and in the Web service project item in LV 2013).  You also need to ensure you are calling the RenderEsp template VI at the end of your web method. 

 

esp snippet.png

Mark
NI App Software R&D
0 Kudos
Message 2 of 5
(6,265 Views)

Re: Not possible to activate Scripting on the Web Server

Hi Mark,

 

thanks for your reply. The document I mentioned is found here (white-paper 7738), it's actually dated oct 30 2013, so there seems to be a mistake here. Since a lot of links refer to that document, it might be a good idea to correct it.

 

I think I have misunderstood one thing. First, I created a static .http document to be the first page, this was called directly and then called a web method (.vi), and so on. This worked fine. But when I added ESP code to that document, nothing worked.

Now I have added a tiny web method, only with the code below, using streaming output type, and then it works fine.

Does this mean, that to use ESP I have to make a web method - I cannot simply embed the ESP code in a static .html file ?

(This wouldn't be a problem of course - I just want to understand Smiley Happy).

 

BR, Jan

 

logon_webmethod.png

Jan Nielsen
Freelance system analyst and LabVIEW programmer
0 Kudos
Message 3 of 5
(6,249 Views)
Solution
Accepted by topic author Jan_Nielsen
08-27-2015 04:09 PM

Re: Not possible to activate Scripting on the Web Server

Hi Jan, 

 

You actually use the ESP file in place of a static HTML file.  For example if we had the static html file:

 

<html>

    <body>

        <h1> Hello, World</h1>

    </body>

</html>

 

this file may be located at something like /MyWebService/HelloWorld.html.

 

If I then wanted to do something like have a page say  "Hello, Jan" or "Hello, Mark" I could use ESP.  In this case your code might look something like:

 

<%

var xname = form['name']; 

%>

 

<html>

    <body>

        <h1> Hello, @@xname</h1>

    </body>

</html>

 

The URL for such an web method may be something like /MyWebService/Hellovar/Jan where Jan string literal passed to the terminal of a web method that may look something like

esp snippet2.png

 

In this example the string "Jan" is passed to the value terminal of the VI.  When setting up the Web method in the build spec its signature would look something like /Hellovar/:value.

 

 

So to go back to your original questions.  You do not embed ESP within and HTML document.  Instead you embed HTML inside an ESP document and the docuement is rendered as HTML when the URL of the Web method is accessed.  The While paper you cited previously has an example project within it that you can use as a reference

Mark
NI App Software R&D
Message 4 of 5
(6,237 Views)

Re: Not possible to activate Scripting on the Web Server

Hi Mark,

 

thanks again for your help. The code is working now and it's good to understand the setup.

 

BR, Jan

Jan Nielsen
Freelance system analyst and LabVIEW programmer
0 Kudos
Message 5 of 5
(6,229 Views)