Passage Server Java API
All Classes
Class WServer
Methods
int Request(String Name, WParamList oParamList, WTableList oTableList)
Runs request with specified name and parameters, and puts result data into the table list.

Parameters:
Name - the request name.
oParamList - the request parameter list.
oTableList - the table list to put result data into.

Returns:
0 if the request is run successfully; -1 otherwise.
int SetOutputPage(String PageName)
Sets the name of html file that will be sent to a browser.

Parameters:
PageName - the html file name [.html is not required].

Returns:
0 if the page is set successfully; -1 otherwise.

Example:
SetOutputPage("mypage");
int Login(String UserName, String UserPwd)
Compares the UserName/Password to match assigned UserName/Password for private requests.

Parameters:
UserName - the user name.
UserPwd - the user password.

Returns:
0 if login is successfull; -1 otherwise.

Example:
Login("john","123"); // returns 0
void SetSessionStatus(int Status)
Makes the session active/inactive, so after request execution the session remains or gets cancelled.

Parameters:
Status - the session status [0 or 1].

Example:
SetSessionStatus(1); // session remains
SetSessionStatus(0); // session cancelled
String GetSessionID()
Returns the session id if session is set active by SetSessionStatus(1) for private requests.

Returns:
a String that represents session id.

Example:
GetSessionID(); // returns 123456890
void SetVar(String Name, String Value)
Creates the variable that can be used by requests within the session.

Parameters:
Name - the variable name.
Value - the variable value.

Example:
SetVar("myvar","123");
String GetVar(String Name)
Returns the variable value.

Parameters:
Name - the variable name.

Returns:
a String that represents the variable value.

Example:
GetVar("myvar"); // returns 123
boolean IsVar(String Name)
Checks if the variable exists.

Parameters:
Name - the variable name.

Returns:
true if the variable exists; false otherwise.

Example:
IsVar("myvar"); // returns true
int Upload(String AppName, WParamList oParamList)
Creates uploaded files on the server.

Parameters:
AppName - the application name to create the files in.
oParamList - the list of file names to assign to the uploaded files. If no names provided, the file names stay as they are uploaded.

Returns:
0 if the files are uploaded successfully; -1 otherwise.
void Trace(String Text)
Puts the text in the server log file ws_app.log

Parameters:
Text - the trace text.

Example:
Trace("my trace message...");
int ScaleImage(String AppNameFrom, String FileNameFrom, String AppNameTo, String FileNameTo, int Width, int Height)
Scales image file in .../AppName/data folder.

Parameters:
AppNameFrom - the application name to scale from.
FileNameFrom - the jpg file name to scale from.
AppNameTo - the application name to scale to.
FileNameTo - the jpg file name to scale to.
Width - the scale width.
Height - the scale height.

Example:
ScaleImage("myapp","mypic_from.jpg","myapp","mypic_to.jpg",400,0); // scales to 400 pixel width
ScaleImage("myapp","mypic_from.jpg","myapp","mypic_to.jpg",0,100); // scales to 100 pixel height
String ReadFile(String AppName, String FileName)
Reads the text file in .../AppName/data folder.

Parameters:
AppName - the application name.
FileName - the file name to read.

Returns:
a String that represents the file content.

Example:
ReadFile("myapp","myfile.txt");
String ReadFileHtml(String AppName, String FileName)
Reads the text file in .../AppName/data folder and replaces all 0D0A found with <br>.
This method is used for showing a content of text file on a html page.

Parameters:
AppName - the application name.
FileName - the file name to read.

Returns:
a String that represents the file content.

Example:
ReadFile("myapp","myfile.txt");
int WriteFile(String AppName, String FileName, String Value)
Writes to the text file in .../AppName/data folder. Overwrites the content if the file already exists.

Parameters:
AppName - the application name.
FileName - the file name to write to.
Value - the text to write.

Returns:
0 if the write is successfull; -1 otherwise.

Example:
WriteFile("myapp","myfile.txt","my text...");
int WriteFileEnd(String AppName, String FileName, String Value)
Writes to the end of the text file in .../AppName/data folder.

Parameters:
AppName - the application name.
FileName - the file name to write to.
Value - the text to write.

Returns:
0 if the write is successfull; -1 otherwise.

Example:
WriteFileEnd("myapp","myfile.txt","my text...");
int DeleteFile(String AppName, String FileName)
Deletes the file in .../AppName/data folder.

Parameters:
AppName - the application name.
FileName - the file name to write to.

Returns:
0 if the file deleted successfully; -1 otherwise.

Example:
DeleteFile("myapp","myfile.txt");
int CopyFile(String AppNameFrom, String FileNameFrom, String AppNameTo, String FileNameTo)
Copies the file in .../AppName/data folder.

Parameters:
AppNameFrom - the application name to copy from.
FileNameFrom - the file name to copy from.
AppNameTo - the application name to copy to.
FileNameTo - the file name to copy to.

Returns:
0 if the file copied successfully; -1 otherwise.

Example:
CopyFile("myapp","myfile_from.txt","myapp","myfile_to.txt");
boolean IsFile(String AppName, String FileName)
Checks if the file exists in .../AppName/data folder.

Parameters:
AppName - the application name.
FileName - the file name to check.

Returns:
true if the file exists; false otherwise.

Example:
IsFile("myapp","myfile.txt");
Example
  api_WServer.java
© PASSAGE