Solved

Cant access the request object only when using java scriplet code

Posted on 2006-06-28
1
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 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