Solved

Cant access the request object only when using java scriplet code

Posted on 2006-06-28
1
402 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache server configuration 7 80
SimpleDateFormat.parse examples 19 87
authenticate preemptively soap ui option 3 123
love6 challenge java 31 129
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
When converting a physical machine to a virtual machine using VMware vCenter Converter Standalone or vCenter Converter Enterprise, if an adapter type is not selected during the initial customization the resulting virtual machine may contain an IDE d…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now