Solved

Cant access the request object only when using java scriplet code

Posted on 2006-06-28
1
405 Views
Last Modified: 2010-04-01
Heres my problem, Im tyring to find a clear way of doing this.  Im inhereting a massive system where the developers called jsp which then calls another jsp and then they used java scriplet code from what I have been told to read the information off the request object.  Now Im trying to modify the code to initially try to put to struts, but now have given that up for now since this would be massive regression test effort.  Does anyone know of way removing the scriplet code and replaceing with java script?  I have modified the page, but cannot for some odd reason in the javascript recognize the HTTP request object.  It only works with java scriplet code.  Then I tried using struts, then reading the request object, and its always null!!

The original code had a name of server hardcoded and now we want it dynamic.
Original
  String HISTORY_SERVER_HOST = "ABCDEFGH";

Now:
  String HISTORY_SERVER_HOST = inputBean.getHistoryServerName();

Also another question I had it seems to automatically know of the application object somehow?  How does that work?

The below code does work... but using scriptlet code... Any advice would be greatly appreciated!!


<%@ taglib uri="/WEB-INF/lib/jakarta-struts-1.0.jar" prefix="struts" %>
<%@ taglib uri="/WEB-INF/lib/jakarta-taglibs-page-1.0.jar" prefix="pg" %>
<jsp:useBean id="ArcHeaderAdaptor" scope="page" class="com.arc.adaptor.ArcHeaderAdaptor"/>
<jsp:setProperty name="ArcHeaderAdaptor" property="session" value= "<%= session %>"/>
<jsp:setProperty name="ArcHeaderAdaptor" property="request" value= "<%= request %>"/>
<%@ page import="arc.web.controller.*"%>
<html>
<head>
<jsp:useBean id="inputBean" scope="session" class="arc.web.model.JSPInputPageBean"/>

<%   //Set Context Path
      String contextPath = "";
      if(application.getServletContextName() != null){
            contextPath = "/" + application.getServletContextName();
      }else{
            contextPath = "";
      }
%>

<%
  String HISTORY_SERVER_HOST = inputBean.getHistoryServerName();
  System.out.println(HISTORY_SERVER_HOST);
  String top_menu = request.getParameter("top_menu");
  String server_name = request.getParameter("server_name");
  String server_title = "";

  if (HISTORY_SERVER_HOST.equalsIgnoreCase(server_name)) {
    server_name = "HISTORY";
  }

  if (!(server_name == null || server_name.equals(""))) {
    server_title = " (" + server_name + ")";
  }
%>
  <title>ARC - <%=inputBean.getTitle() + server_title %> - KRDC</title>
0
Comment
Question by:TheVeee
1 Comment
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 500 total points
ID: 17006986
First thing first... Java script & java scriptlet inside jsp are two very different things and can not be replaced with each other...
Java Script runs on the client side while the scriptlet is executed on server side....

to answer your second question... JSP has a bunch of pre defined variabled and application is one of them...

to get the whole list of them please check out this link..

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPIntro7.html

looks like you are new to JSP... I suggest to go thru this whole tutorial
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the biggest threats in the cyber realm pertains to advanced persistent threats (APTs). This paper is a compare and contrast of Russian and Chinese APT's.
In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question