Reputation: 429
I am trying to create a sequence diagram for a web-based application which is being run using TomCat as a local host.
The application enables users to enter text into a text box and save it to a directory within TomCat.
I am having trouble defining the objects for this.
So far I have "ACTOR-CreateText.jsp-Application Server"
The sequence of events are as follow:
How to display this this on a sequence diagram?
Upvotes: 1
Views: 7397
Reputation: 29621
As web applications are built using HTTP request/response pairs, I find that it helps to capture this in sequence diagrams. It also helps to think about the type of HTTP command you issue for each request - GET, POST etc., and which requests require authentication or state. Where the application uses status codes - e.g. "redirect", or "authentication required", I like to include these too.
I don't usually model the user in this process - the point is usually not to model the user interaction (which buttons they click etc.); however, I do include relevant JavaScript functions which execute in the browser (e.g. "WaitForInput()").
So, for your example, it might be something like:
Browser: GET index.jsp -> ServletContainer
ServletContainer: 200: index.jsp ->Browser
Browser: GET enterText.jsp -> ServletContainer
ServletContainer: 200: enterText.jsp -> Browser
Browser: POST: enterText.jsp(text) -> ServletContainer
ServletContainer: validateEntry() -> ServletContainer
if(valid)
ServletContainer: 200: success.jsp(fileName) -> Browser
else
ServletContainer: 501: fail.jsp(reason)
endif
Upvotes: 1
Reputation: 8664
When defining an "Actor" you should know that definition
An Actor models a type of role played by an entity that interacts with the subject (e.g., by exchanging signals and data), but which is external to the subject (i.e., in the sense that an instance of an actor is not a part of the instance of its corresponding subject). Actors may represent roles played by human users, external hardware, or other subjects. Note that an actor does not necessarily represent a specific physical entity but merely a particular facet (i.e., "role") of some entity that is relevant to the specification of its associated use cases. Thus, a single physical instance may play the role of several different actors and, conversely, a given actor may be played by multiple different instances
In your system, we could say that the Actors are ( User, Web browser, Web server (Application, Content database) )
.
Our next step will be defining the "Call Messages" and "Return Messages" between our actors.
A message defines a particular communication between Lifelines of an Interaction.
As per your events mentioned, we will try to break it down a little more to explain them better.
- User Loads Application.
- [User] ----"RequestResource()"---> [Web Browser]
- [Web Browser] -----"RequestAccessForUser()"---> [Web Server]
- [Web Server] ------"CheckUserExists()"-----> [Content Database]
- [Content Database] ---"Exists Return Message" ----> [Web Server] - Keep returning the response to the user and loads your page on his browser.
Here you can find that there's a probability that user isn't registered, then there's something called "Alternative paths".
OF course you can minimize the steps by decreasing actors number but for learning and simplicity that will be a very good solution. Below are some examples and tutorials will definitely help.
Visual Paradigm introduction to write your first Sequence Diagram
Upvotes: 2