Is it possible to get the current URL in my JSP page.

Say i open a site "http://abc.com/page1.jsp"
I want to display it in page1.jsp the total url as "http://abc.com/page1.jsp" If yes please tell me the step!

Thanks in Advance

Any one? is that not possible..?

any example would be helpful! Pls

any example would be helpful! Pls

Does the getRequestURL() need any example?

Reconstructs the URL the client used to make the request.

classic example of "gif mi zu koduz", aka a homework kiddo that can't be bothered to do its own homework.
It probably didn't even bother to read the documentation I supplied, far too much trouble.

I guess he should realy show more interest in this case but he may be too busy with his blog. ;) <offTopic>Interesting things, but not coolest in my opinion</offTopic> I hope he will at least say thank you

classic example of "gif mi zu koduz", aka a homework kiddo that can't be bothered to do its own homework.
It probably didn't even bother to read the documentation I supplied, far too much trouble.

I guess he should realy show more interest in this case but he may be too busy with his blog. ;) <offTopic>Interesting things, but not coolest in my opinion</offTopic> I hope he will at least say thank you

bro thanks a lot.. was out of station for some days so wasn't replying.. thanks again... Sorry for late reply.. :)

Since this appears first on google for some related searches, it would be nice to have the answer, even if it is one line.

To get the full url:
String url = (request.getRequestURL()).toString();[/java][code=java]String url = (request.getRequestURL()).toString();[/java]

I am looking for the answer to this, too. Our server used to use JRun and now uses Tomcat/JBoss. We cannot know the port number used to access the JSP since JRun got it from the URL itself while Tomcat/JBoss gets the port number from the HTTP request header for the host name. Unfortunately because of this, many of our client requests did not include the port number in the request header. When I RTFM, the documentation said that it recreates...I'm going to guess that it will be recreated without the port number.

<%
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
int rows = 0;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"amar","amar123");
try{
Statement st = con.createStatement();
String query = "select count(*) from user_Register";
ResultSet rs = st.executeQuery(query);

while (rs.next()) {
rows =rs.getInt(1);

%>

i hope this will help u

commented: Ignoring question, ignoring code tags and showing sample of bad programming practice -2

@ravi_fab69
1. You completely disregarded question and provided "code" for something else
2. You completely ignored forum rules to always wrap programming code within posts in code-tags
3. Get your self slap on hand for doing database connection directly from page instead of servlet

<%
  String getURL=request.getRequestURL().toString();
%>
<%=getURL%>
commented: zombie master -3

Or you could just do this:

<%=request.getRequestURL()%>

or you could just read the original post before adding your nonsense.

I think it is work <%=(String)request.getRequestURL()%>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.