Link to home
Start Free TrialLog in
Avatar of TheVeee
TheVeeeFlag for United States of America

asked on

Cant access the request object only when using java scriplet code

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>
ASKER CERTIFIED SOLUTION
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial