use of javax.servlet.RequestDispatcher in project bil372-proje by mertserezli.
the class TaskDescriptionServlet method doGet.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
TaskBean task = new TaskBean();
RequestDispatcher dispatcher;
ServletContext context = getServletContext();
int tid = Integer.parseInt(request.getParameter("tid"));
task.setTid(tid);
try {
task = TaskDAO.getTask(task);
request.setAttribute("task", task);
dispatcher = context.getNamedDispatcher("task");
dispatcher.forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}
use of javax.servlet.RequestDispatcher in project bil372-proje by mertserezli.
the class TaskTreeServlet method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
ProjectBean project = new ProjectBean();
RequestDispatcher dispatcher;
ServletContext context = getServletContext();
int pid = Integer.parseInt(request.getParameter("pid"));
project.setPid(pid);
try {
project = ProjectDAO.getProject(project);
if (!project.getTitle().equals("Project Not Found")) {
String tree = getTreeHTML(project);
ArrayList<UserBean> employeeList = ProjectDAO.getEmployees(project);
request.setAttribute("employeeList", employeeList);
request.setAttribute("tree", tree);
request.setAttribute("project", project);
dispatcher = context.getNamedDispatcher("taskTree");
dispatcher.forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of javax.servlet.RequestDispatcher in project ovirt-engine by oVirt.
the class VersionFilter method doFilter.
private void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
// Get a reference to the object that stores the information of the current request:
Current current = CurrentManager.get();
// Get the remote address, as we need it for several things:
String remoteAddress = request.getRemoteAddr();
// First try to extract the version from the request path:
String version = null;
VersionSource source = null;
String path = current.getPath();
Matcher matcher = VERSION_PATTERN.matcher(path);
if (matcher.matches()) {
version = matcher.group(VERSION_GROUP);
path = matcher.group(PATH_GROUP);
source = VersionSource.URL;
}
// If the version hasn't been determined yet, then try to extract it from the headers:
if (version == null || version.isEmpty()) {
version = request.getHeader(VERSION_HEADER);
if (version != null && !version.isEmpty()) {
source = VersionSource.HEADER;
}
}
// Finally, if the version hasn't been determined, then use the default:
if (version == null || version.isEmpty()) {
version = defaultVersion;
source = VersionSource.DEFAULT;
}
// Check that the version is supported, and return an HTTP error response if it isn't:
if (!supportedVersions.contains(version)) {
log.error("Client \"{}\" is requesting unsupported version \"{}\", will send a 400 error code.", remoteAddress, version);
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
// Check if the version is deprecated, if it is then send a message to the audit log:
if (deprecatedVersionsSet.contains(version)) {
DeprecatedVersionInfo versionInfo = deprecatedVersionsMap.get(version);
AddDeprecatedApiEventParameters parameters = new AddDeprecatedApiEventParameters(version, remoteAddress, versionInfo.getDeprecating(), versionInfo.getRemoving());
backend.runAction(ActionType.AddDeprecatedApiEvent, parameters);
}
// Copy the version, the source and the path to the object that stores information to the current request:
current.setVersion(version);
current.setVersionSource(source);
current.setPath(path);
// modified request.
if (source == VersionSource.URL) {
chain.doFilter(request, response);
} else {
String prefix = current.getPrefix();
String uri = request.getRequestURI();
StringBuilder buffer = new StringBuilder(2 + version.length() + (uri.length() - prefix.length()));
buffer.append("/v");
buffer.append(version);
buffer.append(uri, prefix.length(), uri.length());
path = buffer.toString();
RequestDispatcher dispatcher = request.getRequestDispatcher(path);
if (dispatcher == null) {
log.error("Can't find dispatcher for path \"{}\", as requested by client \"{}\", will send a 404 error code.", path, remoteAddress);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
dispatcher.forward(request, response);
}
}
}
use of javax.servlet.RequestDispatcher in project ovirt-engine by oVirt.
the class GwtDynamicHostPageServlet method doGet.
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
final String engineSessionId = getEngineSessionId(request);
// Set attribute for selector script
request.setAttribute(MD5Attributes.ATTR_SELECTOR_SCRIPT.getKey(), getSelectorScriptName());
// Set the messages that need to be replaced.
request.setAttribute(MD5Attributes.ATTR_MESSAGES.getKey(), getBrandingMessages(getApplicationTypeFromRequest(request), getLocaleFromRequest(request)));
request.setAttribute(MD5Attributes.ATTR_BASE_CONTEXT_PATH.getKey(), getValueObject(ServletUtils.getBaseContextPath(request)));
request.setAttribute(MD5Attributes.ATTR_DISPLAY_UNCAUGHT_UI_EXCEPTIONS.getKey(), getDisplayUncaughtUIExceptions() ? BooleanNode.TRUE : BooleanNode.FALSE);
// Set attributes for userInfo object
DbUser loggedInUser = getLoggedInUser(engineSessionId);
if (loggedInUser != null) {
String ssoToken = getSsoToken(engineSessionId);
request.setAttribute(MD5Attributes.ATTR_USER_INFO.getKey(), getUserInfoObject(loggedInUser, ssoToken));
}
// Set attribute for engineRpmVersion object
String engineRpmVersion = getEngineRpmVersion(engineSessionId);
request.setAttribute(MD5Attributes.ATTR_ENGINE_RPM_VERSION.getKey(), getValueObject(engineRpmVersion));
try {
// Calculate MD5 for use with If-None-Match request header
String md5sum = getMd5Sum(request);
if (request.getHeader(IF_NONE_MATCH_HEADER) != null && request.getHeader(IF_NONE_MATCH_HEADER).equals(md5sum)) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
} else {
RequestDispatcher dispatcher = request.getRequestDispatcher(HOST_JSP);
response.setContentType(UTF_CONTENT_TYPE);
response.addHeader(ETAG_HEADER, md5sum);
if (dispatcher != null) {
dispatcher.include(request, response);
}
}
} catch (NoSuchAlgorithmException ex) {
throw new ServletException(ex);
}
}
use of javax.servlet.RequestDispatcher in project dataverse by IQSS.
the class ApiRouter method doFilter.
@Override
public void doFilter(ServletRequest req, ServletResponse sr1, FilterChain fc) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
String requestUri = request.getRequestURI();
if (requestUri.startsWith("/api/v1/")) {
fc.doFilter(req, sr1);
} else {
String newRequestUri = "/api/v1" + requestUri.substring(4);
RequestDispatcher dsp = request.getRequestDispatcher(newRequestUri);
dsp.forward(req, sr1);
}
}
Aggregations