Thursday, 21 March 2019

Allow access of WAMP server from another system (Forbidden : You don't have permission to access / on this server.)

When we install WAMP server on new system, if it is installed successfully, it works fine on system, but when we try to access it from another system we got error like-



Let see how it can be resolved ?

For WAMP server > 3

Click on WAMP icon in the tray of icons situated in right hand side of task bar. Then click on Apache -------> httpd-vhosts.conf



httpd-vhosts.conf file will be opened with following text -

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

Change Requie local line to Require all granted

Now httpd-vhosts.conf will look like -

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
   Require all granted
  </Directory>
</VirtualHost>

Then save the file and restart the server.

You should also check the colour of WAMP server icon in tray, it should be green.

For WAMP server < 3


If you have installed WAMP server version less than 3, the you have to change in httpd.conf file and search offlineonline tag in the file and replace it from

#   onlineoffline tag - don't remove
    Order Deny, Allow
    Deny from all

to


#   onlineoffline tag - don't remove
    Order Allow,Deny
    Allow from all

and save the file then restart the server.

Another way to resolve it to check that server is offline or online.

Click on WAMP icon in tray and the click on Put Online (See the WAMP icon in Offline Mode and Online mode, there is a change in icon)





Thursday, 27 December 2018

How to make bootable pen drive?

Now days use of CD/DVD has become obsolete. Prior to pen drive in existence, we had to keep the bootable CD/DVD of operating systems if we use desktop PC. Now days CD/DVD not necessarily  required to install OS on PC. You can install your desired OS by making your pen drive bootable. So to make any OS to boot from pen drive you required :-

  • .ISO (Windows xp, 7, 10, Ubuntu, Fedora etc) image of operating system.
  • UltraISO software (You can use trial version).
  • Pen drive 
I have used UltraISO Premium Edition, version 9.6.6.3300.

Install UltraISO if it require installation and open it as "Run as administrator".


User Access Control will prompt click Yes and then Continue to try.


Now go to File ---> Open and then select your OS ISO image file from saved location.



Now go to Bootable menu then select Write Disk Image...

Now verify that in Disk Drive there should be your pen drive. In image file there should be a location of your OS ISO location path and write method should be USB HDD+. If everything is OK, click on Write button. (Note:- your all previous data of pen drive will be erased.) 


You will be asked for confirmation, click on Yes to proceed. Wait till completion of process.


Wait till full writing of image on pen drive. You will see "Burn successful " in message box.


Now safely eject your pen drive and install your OS from pen drive. Make sure that you system BIOS should be  set to boot from pen drive (USB FDD or USB HDD or Flash Drive options in BIOS).









Saturday, 8 December 2018

When automatic repairs fails on boot in Windows Server 2016./How to reapair MBR (Master Boot Record).

Due to direct power off of my Windows Server 2016, it failed to boot and always stuck on automatic repair screen and advanced options.


Let see how can I overcome from this problem on my Windows Server 2016.

1. I choose command prompt, after some time I got elevated command prompt screen.

2. I typed diskpart. This command will bring diskpart tool on command prompt screen.

3. Then I typed list volume. It shows all drives and their label and drive letters (e.g. C, D, E etc). You have to identify what is the drive letter of your OS, in my case, it was C. After identifying my OS drive, I exited from diskpart.

4. To exit I typed exit.  After exiting diskpart, you will be again on command prompt.


5. After exiting from diskpart tool. Go to your OS drive from command prompt. (In my case C is my OS drive letter then I typed C: and press enter)

6. I typed bootrec /fixmbr. 

7. After successful completion of above command, I typed bootrec /fixboot.



8. After successful completion of above command, I typed chkdsk /f /r. This command asked for my confirmation in just y/n . I typed Y. This command took too much time to fix issues. But finally it was successful.

(If again problem persist, then repeat this process again and use a command bootrec /rebuildbcd before chkdsk /f /r)



After restarting my Windows Server PC, my PC was able to boot successfully and everything was as it as my previous one.

Good luck!!! 

Monday, 22 October 2018

Show / Print a variable value in input type field in Servlet.

Generally in Servlet we use HTML in Java (Java --->HTML), but in above we have to write Java ----> HTML -----> Java. So, we can write this in following manner

A simple Sevlet code can be like -

out.println("<table border='1' cellspacing='3' cellpadding='2'>");

If we want double quote instead of single quote in HTML properties value then code will be -

out.println("<input type=\"hidden\" name=\"place\" value=\"any value\">");

And finally when we want any variable value in value property of input type, then code will be -

out.println("<input type=\"hidden\" name=\"place\" value=\""+ variable +"\">");

Saturday, 20 October 2018

Make back button working in action bar in Android.

Recently I was trying to use working back button on my one of the project, but whatever I was done previously was not working. It was a crash every time with error message -


I am newbie to Android, but I was done back activity few day back but after updating my Android Studios and APIs nothing was working. I was also uses  inflated menu in my project, and debugger always stuck in onOptionsItemSelected(MenuItem item) method which I was used for option menu. I also tried many unsuccessful lines of code. Finally I got this solution for my problem -

1 .  In  onCreate(Bundle savedInstanceState) method use -

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);

2 .  Override methos in your activity class

@Overridepublic boolean onSupportNavigateUp() {
    onBackPressed();
    return true;
}


3 . In onOptionsItemSelected(MenuItem item) method use -

switch (item.getItemId()) {  
       case android.R.id.home:
        Intent i = new Intent(this, Your_Parent_Activity.class);
        intent.addFlags(i.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(i);
        return true;
}


Monday, 8 October 2018

File listing and download using hyperlink in JSP from any folder.

Why I am writing this blog? In network some times we don't have server/FTP server(I personally think that it is not more interactive, i.e it can't be in a form of web page) and we have to share any file/s to more than 50 people, then we stuck in messages like "No more connections can be made.. bla bla bla" or either network restriction policy don't allow to do so. Apart from this there may be other issues that can stop to access shared folders in network. I have seen all these kind of problem in accessing shared documents.

So I tried to make web page like application where user can view and download their files via web page. For that you require obviously Tomcat Server for running JSP pages.

So, you should have working knowledge of Tomcat Server.

Create a JSP page and save in your project directory and use this code.

   <p><% 
File folder = new File("G:\\tomcatserver\\webapps\\softshare\\share\\fonts");
File[] listOfFiles = folder.listFiles();
%><table><%
     for (int i = 0; i < listOfFiles.length; i++) {
      if (listOfFiles[i].isFile()) {
String pp="share/fonts/"+listOfFiles[i].getName();
%><tr><td width="500px"><a href="<%=pp%>"><%=listOfFiles[i].getName()%></a><%
   %></td><td><%
Path path=Paths.get(listOfFiles[i].getPath());
BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
out.println(attr.creationTime().toString().substring(0,10));
out.println(" </td></tr>");
      }
    }
%></table><%
 %></p>

Now lets see the code in details-

File folder = new File("G:\\tomcatserver\\webapps\\softshare\\share\\fonts"); //path of folder
File[] listOfFiles = folder.listFiles(); // will store file in array.

This code will read the files of fonts/ folder. The font folder should be in your project directory, it should not be out your tomcat server.

 String pp="share/fonts/"+listOfFiles[i].getName();

pp will store the relative path of files.

Now you will be able to list and download your file via hyperlink.

Thursday, 4 October 2018

Add app bar / action bar / tool bar and menu in Android Studio.

App bar or action bar or tool bar is a dedicated bat on the top of the every app/activity. It is also called title bar of activity. It may contain toolbox/icon or overflow menu or can be both.


So how can we create this action bar in your project?

1. create menu.xml file in res/menu directory of your project. To create go to -

New ---> Android Resource File

Enter the file name (should start with small letters alphabets) then select resource type as menu then click Ok.


Now create menu by adding items in this menu.xml file.

<item android:title="Item 1"></item>
<item android:title="Item 2"></item>
<item android:title="Item 3"></item>
<item android:title="Item 4"></item>

The complete menu.xml is-

<?xml version="1.0" encoding="utf-8"?><menu xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item android:title="Item 1"></item>
    <item android:title="Item 2"></item>
    <item android:title="Item 3"></item>
    <item android:title="Item 4"></item>
</menu>


2. After creating menu, you require it to inflate on title bar/action bar. To inflate, write given below code in you activity

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater in=getMenuInflater(); in.inflate(R.menu.menu,menu); return super.onCreateOptionsMenu(menu); }

After running your program you can see the menu in action bar, when you click on three dots on left side of action bar like -


If you want to add icon or tool box on the action bar then in menu.xml file, use icon property of item tag and select any .png image from your res/mipmap directory, like (You can see home icon in screen shot given below)  

<item android:title="home"    android:icon="@mipmap/home"    app:showAsAction="always"></item>




Change image source dynamically on hyperlink

 Changing image source dynamically using JQuery. Here in this example I have created there hyperlink and stored all images in the same folde...