This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Portals and Portlets and the fly likes I need help regarding getting the URL that is Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "I need help regarding getting the URL that is "http://localhost:9080/"." Watch "I need help regarding getting the URL that is "http://localhost:9080/"." New topic
Author

I need help regarding getting the URL that is "http://localhost:9080/".

sana sultana
Greenhorn

Joined: Jan 17, 2011
Posts: 2
Hello,

I need help regarding getting the URL that is "http://localhost:9080/".

I am working on a JSF Application with RAD and websphere portal server. From one of my page when i clicked on PDF symbol a new window pops up which runs on Websphere App Server. It should have the url as "http://localhost:9080/.....". instead it shows
shows the portal server port number "http://locathost:10039".

as of now am hardcoding it in my Jsp but i need a way to get this url from Application Context instead of hardcoding.


any help in this regard will be appreciated.


Thank you
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

What you are looking for is:
request.getContextPath();

so say in portlet use: <img src="<%=request.getContextPath()>/images/test.jpg">

Also, in websphere portal the installation make two server instances:
1. server1 which runs at http port 9080 (default).
2. WebSphere_Portla which runs at http port 10040 (default).

Hope it solves your problem.

SCJP 91%, SCWCD 97%
sana sultana
Greenhorn

Joined: Jan 17, 2011
Posts: 2
no my provlem will not be solved with this.


i have 2 ear files deployed on 2 different servers

for example A on Portal and B on webApp Server

a jsp from A will pop up a new window when clicked on the PDF Icon by calling the Java Script

function open_report(commId, formName, thisEvent) {
<%String user = renderRequest.getRemoteUser();%>
var idUser = "<%= user %>";
var appUrl = "<%=ApplicationConstants.APP_SERVER_LOCALHOST%>"+"<%= MTPResources.getReportServletURL()%>";

window.open (""+appUrl+"?idReport="+commId+"&formName="+formName+"&idUser="+idUser,
"mywindow", "alwaysRaised=yes,toolbar=yes,scrollbars=yes,left=100,top=100,width=800,height=600,resizable=yes");
return false;
}

***********************************************************************************************************
ApplicationConstants.APP_SERVER_LOCALHOST gives http://localhost:9080 which is hardcoded
and MTPResources.getReportServletURL() gives /B/ReportServlet this reportServlet is in ws_mtp(deployed in websphere App Server) and renderRequest.getContextPath() will give ./A
************************************************************************************************************


since i have hardcoded it pop up window has the following Path in the address bar
http://localhost:9080/B/ReportServlet?idReport=396460402&formName=H3006&idUser=wpadmin

else it would have given

http://localhost:10039/B/ReportServlet?idReport=396460402&formName=H3006&idUser=wpadmin
and a Blank page will be displayed.

i want to get
http://localhost:9080/ without hard coding. Hope you have understood what i am trying to explain.

any help will be appreciated.

Thank you.
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

First of all this cannot be resolved by server through any standard api.
But hardcoding could be easily removed by:

1. One thing you can do is maintain a propery file containing:
SERVER_LOCALHOST=http://localhost:9080
and read the value from it upon server startup and store it in:
ApplicationConstants.APP_SERVER_LOCALHOST

2. you can put the value in Server A's Enviroment Varibales.
And read the value from server.
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
If the remote servler host:port are required by one particular portlet, then you can also use portlet preferences (portlet.xml) instead of property files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I need help regarding getting the URL that is "http://localhost:9080/".
 
Similar Threads
HTTP 404 not found
make default.jsp as home page
Why I'm getting Web group exception while accessing html?
ravula62020
Changing URL from IP to Domain Name