|How to make a login/session?|
|How to work with a database?|
|How to use a database connection pool?|
|How to upload a file?|
|How to use external Java library [jar]?|
How to make a login/session?
Use API method oServer.Login(UserName)
There are three steps:
#1. In Passage Studio create a user, set requests [that require security] private, i.e. Access: Private, and assign them to this user.
#2. In your project database most likely you have a table with project users. Write "your project login" request to check if user web input UserName/Password is matching the project database user.
#3. If matching, call oServer.Login(UserName), it creates a session and a cookie "jsessionid".
If not matching, return login page.
To close a session, write "your project logout" request, in which call oServer.Logout() method.
A session will be automatically closed based on Application Session Timeout setting in Passage Studio.
User API methods oServer.SetCookie(name,value) and oServer.GetCookie(name).
API methods oServer.SetVar(...) and oServer.GetVar(...) are used for managing required application data in a session.
How to work with a database?
There are four steps:
#1. Create ODBC data source.
#2. Create data source in Passage Studio with the same name as created in #1.
#3. Create SQL Request, i.e. Request with Language: SQL, with a datasource created in #2, write SELECT, INSERT, UPDATE, DELETE statement according to your business logic.
#4. Create Java Request, i.e. Request with Language: Java, in which run SQL Request created in #3 using API method oServer.Request(...).
Result of SELECT statement is coming as WTable. Result of INSERT, UPDATE, DELETE is empty.
You do not embed SQL code into Java code, instead you run SQL Request from Java Request.
The server restart is not required.
How to use a database connection pool?
Database connection pool is automatically managed by Passage Server.
You control the size of the pool, which is a number of database connections in Passage Studio.
After changing the number, the server restart is not required.
How to upload a file?
There are two steps:
#1. Make HTML form with ENCTYPE="multipart/form-data", and put INPUT control of TYPE="FILE".
#2. Create Java Request, use API method WFile.Upload(...), which creates a file with a provided name on a server, by default in appname/data folder.
How to use external Java library [jar]?
Put jar file into Passage Server Java folder [where ws.jar and mail.jar files are].
In your Java code provide corresponding "import".
The server restart is required.
Loaded jar files are shown in ws_start.log